/*
 * File: NthFromEnd.java
 * 
 * Date		Author		Changes
 * ----------------------------------------------------------------
 * 12 Feb 1998	M Ravishankar	Created
 */

import java.io.*;	// Needed because we want to read from standard input.

/**
 * Main class for this application.  Function:
 *   Read one line from the standard input (terminal or piped file).
 *   If the 5th <b>letter</b> from the end is an 'a', and the 3rd <b>digit</b> from
 *   the end is a '0', accept the string.  Otherwise reject the string.
 * 
 * Example session, including compiling and then running the program several times:
 * <pre>
 *   % javac NthFromEnd.java	(compile the program)
 *   % java NthFromEnd		(run the program)
 *   aaaaaaaaa000000		(input)
 *   Accept			(output)
 *   % java NthFromEnd
 *   aaaaabbbbb0000 
 *   Reject
 *   % java NthFromEnd
 *   ab   d   0 dd 3 2
 *   Accept
 * </pre>
 * What happens if you type in <code>aaaaaa</code> as input?
 * 
 * Implemented as follows:
 * Push letters onto one stack, and digits onto another stack.  Upon end of line,
 * pop 4 characters off the first and 2 characters off the second stack.  Then check
 * the top of the two stacks for 'a' and '0', respectively.
**/

public class NthFromEnd
{
  /*
   * Declaring the following constants <code>final</code> makes them unchangeable.
   */
  static final int NLETTER = 5;	// Letter position from the end to be checked for 'a'
  static final int NDIGIT = 3;	// Digit position from the end to be checked for '0'
  
  /*
   * main method.  <code>throws IOException</code> because reading standard input can
   * cause IOException.
   * A good program should actually catch and deal with the exception.
   */
  public static void main (String args[]) throws IOException {
    Stack s1;	// Reference to Stack object (for letters)
    Stack s2;	// Reference to Stack object (for digits)
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String line;
    
    s1 = new Stack();	// Allocate Stack object for letters
    s2 = new Stack();	// Allocate Stack object for digits
    
    /*
     * Read one line at a time from standard input, and push
     * letters into s1, and digits into s2.
     */
    if ((line = in.readLine()) != null) {
      for (int i = 0; i < line.length(); i++) {
	if (Character.isLetter(line.charAt(i)))
	  s1.push (line.charAt(i));
	
	else if (Character.isDigit(line.charAt(i)))
	  s2.push (line.charAt(i));
      }
    }
    
    /*
     * Pop NLETTER-1 characters off s1, and NDIGIT-1 characters off s2.  (Ignore the
     * returned characters in both case.)
     * Bug-note: What if there are fewer than the sought for characters in a stack??
     */
    for (int k = 0; k < NLETTER-1; k++)
      s1.pop ();
    for (int k = 0; k < NDIGIT-1; k++)
      s2.pop ();
    
    /*
     * Now pop the topmost characters off s1 and s2 and check for 'a' and '0'
     */
    if ((s1.pop()=='a') && (s2.pop()=='0'))
      System.out.println("Accept");	// Prints "Accept" and a newline
    else
      System.out.println("Reject");	// Prints "Reject" and a newline
  }
}
