local read, write = io.read, io.write local num, nl = '*n', '\n' local t t = read(num) while t > 0 do t = t-1 local str str = read(num) local l = string.len(str) local i,count = 0,0 while i < l do local j = 0 while j < l do if string.byte(str,i) == string.byte(str,j) then count = count+1 end end end write(count) write("\n") end