import java.util.Scanner;

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

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