uses math;
var
t,i:longint;
s:string;
function c1(s:string):longint;
begin
c1:=0;
while pos('tokyo',s)>0 do
begin
inc(c1);
delete(s,pos('tokyo',s),5);
end;
end;
function c2(s:string):longint;
begin
c2:=0;
while pos('kyoto',s)>0 do
begin
inc(c2);
delete(s,pos('kyoto',s),5);
end;
end;
begin
readln(t);
for i:=1 to t do
begin
readln(s);
writeln(max(c1(s),c2(s)));
end;
end.
RT.但是洛谷IDE和本地FP都可以通过。