f xs [] = 0 f xs yys@(y:ys) = g xs yys `max` (1 + g xs ys) `max` f (y:xs) ys g xs ys = length (filter id $ zipWith (==) xs ys) * 2 main = print . f [] =<< getLine