
f [] [] [] i = i
f (x:xs) (y:ys) (z:zs) i
  | x == y && y == z = f xs ys zs i
  | x /= y && y /= z && z /= x = f xs ys zs (i + 2)
  | otherwise = f xs ys zs (i + 1)

main = do
  getLine
  a <- getLine
  b <- getLine
  c <- getLine
  print $ f a b c 0
