import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x, y, z, GCD, GCD_n;
    x = sc.nextInt();
    y = sc.nextInt();
    if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    }
    GCD = y;
    GCD_n = x % GCD;
    while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    }
    System.out.println(GCD);
    sc.close();
  }
}
 import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x, y, z, GCD, GCD_n;
    x = sc.nextInt();
    y = sc.nextInt();
    if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    }
    GCD = y;
    GCD_n = x % GCD;
    while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    }
    System.out.println(GCD);
    sc.close();
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x, y, z, GCD, GCD_n;
    x = sc.nextInt();
    y = sc.nextInt();
    if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    }
    GCD = y;
    GCD_n = x % GCD;
    while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    }
    System.out.println(GCD);
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    int x, y, z, GCD, GCD_n;
    x = sc.nextInt();
    y = sc.nextInt();
    if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    }
    GCD = y;
    GCD_n = x % GCD;
    while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    }
    System.out.println(GCD);
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x x y y z z GCD GCD GCD_n; GCD_n x = sc.nextInt() x sc.nextInt() sc.nextInt sc y = sc.nextInt() y sc.nextInt() sc.nextInt sc if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    } x < y x y { //swap
      z = x;
      x = y;
      y = z;
    } z = x z x x = y x y y = z y z GCD = y GCD y GCD_n = x % GCD GCD_n x % GCD x GCD while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    } GCD_n != 0 GCD_n 0 {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    } x = GCD x GCD GCD = GCD_n GCD GCD_n GCD_n = x % GCD GCD_n x % GCD x GCD System.out.println(GCD) System.out.println System.out System System.out GCD sc.close() sc.close sc String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x, y, z, GCD, GCD_n;
    x = sc.nextInt();
    y = sc.nextInt();
    if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    }
    GCD = y;
    GCD_n = x % GCD;
    while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    }
    System.out.println(GCD);
    sc.close();
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x, y, z, GCD, GCD_n;
    x = sc.nextInt();
    y = sc.nextInt();
    if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    }
    GCD = y;
    GCD_n = x % GCD;
    while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    }
    System.out.println(GCD);
    sc.close();
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x, y, z, GCD, GCD_n;
    x = sc.nextInt();
    y = sc.nextInt();
    if (x < y) { //swap
      z = x;
      x = y;
      y = z;
    }
    GCD = y;
    GCD_n = x % GCD;
    while(GCD_n != 0) {
      x = GCD;
      GCD = GCD_n;
      GCD_n = x % GCD;
    }
    System.out.println(GCD);
    sc.close();
  }
}

