// $Id: ackermann.java,v 1.4 2000/10/07 08:41:43 doug Exp $
// http://www.bagley.org/~doug/shootout/

public class ackermann {

    public static void main(String args[]) {
    int NUM = Integer.parseInt(args[0]);
    System.out.print("Ack(3," + NUM + "): " + Ack(3, NUM) + "\n");
    }

    public static int Ack(int M, int N) {
    if (M == 0) return( N + 1 );
    if (N == 0) return( Ack(M - 1, 1) );
    return( Ack(M - 1, Ack(M, (N - 1))) );
    }

}