s = io.read() ss = {} n = string.len(s) tall = {} function getlen(spos, epos) len = 0 while(spos <= epos) do if(ss[spos] == ss[epos]) then if(spos == epos) then len = len + 1 else len = len + 2 end end spos, epos = spos + 1, epos - 1 end return len end for i = 1, n do a = string.sub(s, i, i) if(tall[a] == nil) then tall[a] = {} end table.insert(tall[a], i) ss[i] = a end maxlen = 1 for k, v in pairs(tall) do if(2 <= #v) then for i = 1, #v - 1 do spos = v[i] for j = i + 1, #v do epos = v[j] maxlen = math.max(maxlen, getlen(spos, epos)) end end end end print(maxlen)