/*****************************************************************
** Palindrome3 - same as Palindrome2, except...
**
** This program uses program traces to help in debugging.
**
** A sample dialogue follows:
**
**    PROMPT>java Palindrome3
**    hello
**    h <---> o
**    NOT A PALINDROME
**    rotator
**    r <---> r
**    o <---> o
**    t <---> t
**    a <---> a
**    Yes, it's a palindrome
**    rotator
**
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import java.io.*;
import java.util.*;

public class Palindrome3
{
   public static void main(String[] args) throws IOException
   {
      // open keyboard for input (call it 'stdin')
      BufferedReader stdin =
         new BufferedReader(new InputStreamReader(System.in), 1);

      // prepare to extract words from lines
      String line;
      StringTokenizer words;
      String word;

      // main loop, repeat until no more input
      while ((line = stdin.readLine()) != null)
      {
         // tokenize the line
         words = new StringTokenizer(line);

         // process each word in the line
         while (words.hasMoreTokens())
         {
            word = words.nextToken();
            if (word.length() > 2 && isPalindrome(word))
               System.out.println(word);
         }       
      }
   }

   public static boolean isPalindrome(String w)
   {
      int i = 0;
      int j = w.length();
      while (i < j)
      {
         System.out.println(w.substring(i, i + 1)
               + " <---> " + w.substring(j - 1, j));
         if (!w.substring(i, i + 1).equals(w.substring(j - 1, j)))
         {
            System.out.println("NOT A PALINDROME");
            return false;
         }
         i++;
         j--;
      }
      System.out.println("Yes, it's a palindrome");
      return true;
   }
}

