import java.util.Scanner;

class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int lower;
    int bigger;
    if (a > b) {
      lower = b;
      bigger = a;
    } else {
      lower = a;
      bigger = b;
    }
    int tmp = bigger % lower;
    while(lower != 0) {
      tmp = bigger % lower;
      bigger = lower;
      lower = tmp;
    }
    System.out.println(bigger);
  }
}
 import java.util.Scanner; Scanner java.util class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int lower;
    int bigger;
    if (a > b) {
      lower = b;
      bigger = a;
    } else {
      lower = a;
      bigger = b;
    }
    int tmp = bigger % lower;
    while(lower != 0) {
      tmp = bigger % lower;
      bigger = lower;
      lower = tmp;
    }
    System.out.println(bigger);
  }
} Main public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int lower;
    int bigger;
    if (a > b) {
      lower = b;
      bigger = a;
    } else {
      lower = a;
      bigger = b;
    }
    int tmp = bigger % lower;
    while(lower != 0) {
      tmp = bigger % lower;
      bigger = lower;
      lower = tmp;
    }
    System.out.println(bigger);
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int lower;
    int bigger;
    if (a > b) {
      lower = b;
      bigger = a;
    } else {
      lower = a;
      bigger = b;
    }
    int tmp = bigger % lower;
    while(lower != 0) {
      tmp = bigger % lower;
      bigger = lower;
      lower = tmp;
    }
    System.out.println(bigger);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int lower; lower int bigger; bigger if (a > b) {
      lower = b;
      bigger = a;
    } else {
      lower = a;
      bigger = b;
    } a > b a b {
      lower = b;
      bigger = a;
    } lower = b lower b bigger = a bigger a {
      lower = a;
      bigger = b;
    } lower = a lower a bigger = b bigger b int tmp = bigger % lower; tmp bigger % lower bigger lower while(lower != 0) {
      tmp = bigger % lower;
      bigger = lower;
      lower = tmp;
    } lower != 0 lower 0 {
      tmp = bigger % lower;
      bigger = lower;
      lower = tmp;
    } tmp = bigger % lower tmp bigger % lower bigger lower bigger = lower bigger lower lower = tmp lower tmp System.out.println(bigger) System.out.println System.out System System.out bigger String... args args
import java.util.Scanner;

class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int lower;
    int bigger;
    if (a > b) {
      lower = b;
      bigger = a;
    } else {
      lower = a;
      bigger = b;
    }
    int tmp = bigger % lower;
    while(lower != 0) {
      tmp = bigger % lower;
      bigger = lower;
      lower = tmp;
    }
    System.out.println(bigger);
  }
}

