import java.util.Scanner;

class Main {  
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    System.out.println(gcd(a, b));
  }
  
  public static int gcd(int x, int y) {
    if      (y == 0) return x;
    else if (x < y)  return gcd(y, x);
    else if (x > y)  return gcd(y, x%y);
    else             return x;
  }
} import java.util.Scanner; Scanner java.util class Main {  
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    System.out.println(gcd(a, b));
  }
  
  public static int gcd(int x, int y) {
    if      (y == 0) return x;
    else if (x < y)  return gcd(y, x);
    else if (x > y)  return gcd(y, x%y);
    else             return x;
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    System.out.println(gcd(a, b));
  } main {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    System.out.println(gcd(a, b));
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String[] args args public static int gcd(int x, int y) {
    if      (y == 0) return x;
    else if (x < y)  return gcd(y, x);
    else if (x > y)  return gcd(y, x%y);
    else             return x;
  } gcd {
    if      (y == 0) return x;
    else if (x < y)  return gcd(y, x);
    else if (x > y)  return gcd(y, x%y);
    else             return x;
  } if      (y == 0) return x;
    else if (x < y)  return gcd(y, x);
    else if (x > y)  return gcd(y, x%y);
    else             return x; y == 0 y 0 return x; x if (x < y)  return gcd(y, x);
    else if (x > y)  return gcd(y, x%y);
    else             return x; x < y x y return gcd(y, x); gcd(y, x) gcd y x if (x > y)  return gcd(y, x%y);
    else             return x; x > y x y return gcd(y, x%y); gcd(y, x%y) gcd y x%y x y return x; x int x x int y y
import java.util.Scanner;

class Main {  
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    System.out.println(gcd(a, b));
  }
  
  public static int gcd(int x, int y) {
    if      (y == 0) return x;
    else if (x < y)  return gcd(y, x);
    else if (x > y)  return gcd(y, x%y);
    else             return x;
  }
}