import java.util.Scanner;



public class GreatestCommonDivisor {

  /** Main method */

  public static void main(String[] args) {

    // Create a Scanner
    Scanner scanner = new Scanner(System.in);



    // Prompt the user to enter two integers
    System.out.print("Enter first integer: ");

    int n1 = scanner.nextInt();

    System.out.print("Enter second integer: ");

    int n2 = scanner.nextInt();



    int gcd = 1;

    int k = 1;

    while (k <= n1 && k <= n2) {

      if (n1 % k == 0 && n2 % k == 0)

        gcd = k;

      k++;

    }



    System.out.println("The greatest common divisor for " + n1 +

      " and " + n2 + " is " + gcd);

  }

}