/* Prog1: a palindrome checker
 * Thomas Kang
 * February 24, 1998
 */

import java.io.*;

/**
 * Invoked when delimiter character is read.
 **/
class EOLException extends Exception {
  public EOLException() { super(); }
  public EOLException(String s) { super(s); }
}

/**
 * Palindrome reads lines from stdin and tests them for palindromes.
 * All white spaces, symbols, and numbers are ignored.  Case is also
 * ignored.  Lines are assumed to be separated by newline characters.
 **/
class Palindrome {
  public Palindrome() {
    candidateString = "";
  }

  /**
   * Prints the current candidate string.
   **/
  public void print() {
    System.out.println(candidateString);
  }

  /**
   * Return <tt>true</tt> if the string is a palindrome, else <tt>false</tt>.
   **/
  public boolean isPalindrome() {
    // test to see if it's a palindrome
    StringBuffer rev = new StringBuffer(candidateString);
    rev.reverse();
    return candidateString.equals(rev.toString()) ? true : false;
  }

  /**
   * Read the next line of input from stdin (terminated by newline),
   * or throw EOFException if EOF is reached.
   **/
  public void readLine() throws EOFException {
    StringBuffer buf = new StringBuffer();

    try {  // keep reading characters from the input stream
      while (true) {
	char c = readNextChar();
	buf.append(c);
      }
    }

    catch(EOLException e) {  // end of line, so set candidate string
      candidateString = new String(buf.toString());
    }

    catch(IOException e) {  // end of file, so throw EOFException
      throw new EOFException();
    }
  }

  /**
   * Return the next letter (A-Z,a-z) in the input stream, converted
   * to lower case; or throw EOLException, if it reads the
   * newline character; or throw java.io.IOException on reaching EOF.
   **/
  private char readNextChar() throws EOLException, IOException {
    while (true) {
      int i = System.in.read();
      char c = (char)i;

      /* test for EOF */
      if (i == -1)  // java.lang.System.in.read() returns -1 on EOF
	throw new IOException();  // since System.in.read() already uses it

      /* test for delimiter */
      if (c == '\n')
	throw new EOLException();

      /* test for letter */
      if (Character.isLetter(c))
	return Character.toLowerCase(c);
    }
  }

  private String candidateString;  // string represented by this object
}

/**
 * Prog1 reads a series of lines from the stadard input and reports
 * Y if it is a palindrome, N if it is not.
 **/

public class Prog1 {
  /**
   * Main program.  A simple read-eval-print loop.
   **/
  public static void main(String[] argv) {
    Palindrome P = new Palindrome();

    try {  // keep running until end of file
      while (true) {
	P.readLine();  // read
	System.out.println( P.isPalindrome() ? "Y" : "N" );  // eval & print
      }
    }
    catch(EOFException e) {}  // EOF, so we're done
  }
}
