local t = io.read("*n", "*l") for i = 1, t do local minmodcount = 100 local str = io.read() local n = #str for j = 1, n - 10 do local jmodcount = 0 if(str:sub(j, j) ~= "g") then jmodcount = jmodcount + 1 end if(str:sub(j + 1, j + 1) ~= "o") then jmodcount = jmodcount + 1 end if(str:sub(j + 2, j + 2) ~= "o") then jmodcount = jmodcount + 1 end if(str:sub(j + 3, j + 3) ~= "d") then jmodcount = jmodcount + 1 end for k = j + 4, n - 6 do local kmodcount = 0 if(str:sub(k, k) ~= "p") then kmodcount = kmodcount + 1 end if(str:sub(k + 1, k + 1) ~= "r") then kmodcount = kmodcount + 1 end if(str:sub(k + 2, k + 2) ~= "o") then kmodcount = kmodcount + 1 end if(str:sub(k + 3, k + 3) ~= "b") then kmodcount = kmodcount + 1 end if(str:sub(k + 4, k + 4) ~= "l") then kmodcount = kmodcount + 1 end if(str:sub(k + 5, k + 5) ~= "e") then kmodcount = kmodcount + 1 end if(str:sub(k + 6, k + 6) ~= "m") then kmodcount = kmodcount + 1 end minmodcount = math.min(minmodcount, kmodcount + jmodcount) end end print(minmodcount) end