public class Pgcd2 {
	public static void main(String[] args) {
		if(args.length != 2) {
			System.out.println("2 arguments required");
			System.exit(1);
		}
		
		int p = Integer.parseInt(args[0]);
		int q = Integer.parseInt(args[1]);
		
		System.out.println("PGCD(" + p + ", " + q + ") =");

		while(p*q != 0) {
			if(p > q) {
				p = p % q;
			} else {
				q = q % p;
			}
		}
		
		if(p == 0) {
			System.out.println(q);
		} else {
			System.out.println(p);
		}

	}
}
