
foo :: [Int] -> [Int] -> Int -> Bool
foo _ _ 3 = False
foo [] [] _ = True
foo (x:xs) (y:ys) num =
  if x == y then foo xs ys num
  else foo xs ys (num+1)

showBool :: Bool -> String
showBool True = "YES"
showBool False = "NO"

main = do
  ints <- map read . words <$> getLine :: IO [Int]
  putStrLn $ showBool $ foo ints [1..length ints] 0
