MODULE Main;
IMPORT Fmt, Scan, Params, Wr, Stdio;

PROCEDURE Ack(M, N: INTEGER): INTEGER =
BEGIN
    IF M = 0 THEN 
        RETURN N+1;
    ELSE
        IF N = 0 THEN
            RETURN Ack(M-1, 1);
        ELSE
            RETURN Ack(M-1, Ack(M, N-1));
        END;
    END;
END Ack;

VAR N: INTEGER;
BEGIN
    IF Params.Count > 0 THEN
        N := Scan.Int(Params.Get(1));
    ELSE
        N := 1;
    END;
    Wr.PutText (Stdio.stdout, "Ack(3," & Fmt.Int(N) & "): " & Fmt.Int(Ack(3, N)));
    Wr.Close (Stdio.stdout);
END Main.