n = io.read("*n") a = 1023 for i = 1, n do t = {} t[1], t[2], t[3], t[4], zz, s = io.read("*n", "*n", "*n", "*n", 1, "*l") v = 0 for j = 1, 4 do v = v + 2^t[j] end if(s == "NO") then v = 1023 - v end -- a = bit32.band(a, v) NOT AVAILABLE FOR LUA 5.1 a, b = 0, a for j = 0, 9 do if(b % 2 == 1 and v % 2 == 1) then a = a + 2^j; b, v = b - 1, v - 1 end b, v = math.floor(b / 2), math.floor(v / 2); end end io.write(string.format("%d\n", math.log(a, 2)))