import Control.Applicative
import Data.Bool (bool)

main :: IO ()
main = solve <$> words <$> getLine >>= putStrLn

solve :: [String] -> String
solve [a, b, c] = bool "NO" "YES" $ last a == head b && last b == head c
