/*
 * %W %E% Salvatore Desiano
 *
 * Copyright (c) 1997 Salvatore Domenick Desiano
 */

package solutions;

import java.io.*;

/**
 * A simple palindrome detector. Input data is taken from standard
 * input, and each line is considered a separate input. A line is
 * delimited by either a line feed, a carriage return, or a carriage
 * return and linefeed in combination (to deal with IBM, Mac, and
 * Unix, respectively). The program terminates on an End Of File
 * marker.<p>
 * 
 * Each input is stripped of non-alphabetic characters, as defined by
 * <tt>Character.isLetter()</tt> (which follows the Unicode 2.0 standard), and is
 * checked for symettry. If the input is symettric, a "Y" is output on a
 * line by itself. Otherwise, a "N" is output in the same manner. Case
 * is ignored.<p>
 *
 * Empty inputs are palindromes. Inputs on the same line with the EOF
 * marker are considered just as any other line, with the exception that
 * a line containing *only* the EOF marker (and no other characters,
 * letter or otherwise) is ignored.<p>
 *
 * @author Salvatore Domenick Desiano
 * @version 1.00, 02/24/98
 */
 
public class prog1 {
  /* uses StringBuffer.reverse() and String.equalsIgnoreCase to check
   * for palindromes.
   */

  /**
   * Performs the entire function of the program, due to the
   * simplicity of the task.  
   */
  public static void main(String[] args) {

    String         input;	// Input buffer
				// Buffer for stripped input
    StringBuffer   clean = new StringBuffer();
				// Buffered reader on standard input
    BufferedReader brInput = new BufferedReader(new InputStreamReader(System.in));


    try {
				// Loop through lines of input
      while (( input = brInput.readLine()) != null ) {
	clean.setLength(0);	// Clear old stripped buffer

				// Strip input and deposit in clean
	for ( int i = 0; i < input.length(); i++ ) 
	  if (Character.isLetter(input.charAt(i)))
	    clean.append(input.charAt(i));

				// Print results
       	System.out.println
	  ((clean.toString().equalsIgnoreCase(clean.reverse().toString()))?
	   "Y":"N");
      }
    }
				// BufferedStream.readLine() throws an
				// IOException
    catch ( IOException ioe ) {
      System.err.println("IO error: " + ioe );
      ioe.printStackTrace();
    }
  }
}
