// Name        : Khaled Alshaya
// Last Update : April 15, 2007
// Palindrome (  Word by Word )
// http://www.ArabTeam2000-forum.com

#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <cctype>
using namespace std;

bool IsPal ( string Str );

int main (){
    string Sentence;
    cout << "Please enter a Sentence :" << endl;
    getline ( cin, Sentence );
    cout << endl << endl;
    if ( IsPal ( Sentence ) )
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

bool IsPal ( string Str ){
    string Word;
    queue <string> PalQ;
    stack <string> PalS;
    int   Counter = 0;
    for ( unsigned int I = 0; I < Str.length(); I++ ){
        if ( isalpha ( Str[ I ] ) && isupper ( Str[ I ]  ) )
            Str[ I ] = tolower ( Str[ I ] );
    }
    while ( Str[ Counter ] ){
        Word = "";
        if ( !(isalpha ( Str [ Counter ] )) && (Str [ Counter ] != '\'') ){
            Counter++;
            continue;
        }
        while ( (isalpha ( Str [ Counter ] )) || (Str [ Counter ] == '\'') ){
            Word += Str[ Counter ];
            Counter++;
        }
        PalQ.push ( Word );
        PalS.push ( Word );
    }
	// First bug fixed by Shreef in ArabteamForum. ( the bug was in the for loop )
	unsigned int WordsCount = PalQ.size();
    for ( unsigned int I = 0; I < WordsCount; I++ ){
        if ( PalQ.front() != PalS.top() )
            return false;
        PalQ.pop(); PalS.pop();
    }
    return true;
}
