import java.util.*;

public class Main {
  public static void main(String[] main){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int gcd = 1;  /* gcd：最大公約数を１に初期化 */
    int small = 0;
    //x.compareTo(y);

    /* x÷y or y÷x が割り切れるとき, 小さい方を最大公約数として返す */
    if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    }
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] main){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int gcd = 1;  /* gcd：最大公約数を１に初期化 */
    int small = 0;
    //x.compareTo(y);

    /* x÷y or y÷x が割り切れるとき, 小さい方を最大公約数として返す */
    if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    }
  }
} Main public static void main(String[] main){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int gcd = 1;  /* gcd：最大公約数を１に初期化 */
    int small = 0;
    //x.compareTo(y);

    /* x÷y or y÷x が割り切れるとき, 小さい方を最大公約数として返す */
    if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    }
  } main {
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int gcd = 1;  /* gcd：最大公約数を１に初期化 */
    int small = 0;
    //x.compareTo(y);

    /* x÷y or y÷x が割り切れるとき, 小さい方を最大公約数として返す */
    if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int gcd = 1; gcd 1 int small = 0; small 0 if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    } (x % y == 0) || (y % x == 0) (x % y == 0) x % y x y 0 (y % x == 0) y % x y x 0 {
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    } if (x > y || x == y) System.out.println(y);
      else System.out.println(x); x > y || x == y x > y x y x == y x y System.out.println(y) System.out.println System.out System System.out y System.out.println(x) System.out.println System.out System System.out x {
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    } if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      } x > y || x == y x > y x y x == y x y {
        x = x % y;
        small = x;
      } x = x % y x x % y x y small = x small x {
        y = y % x;
        small = y;
      } y = y % x y y % x y x small = y small y for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      } int i = 1; int i = 1; i 1 i <= small i small i++ i++ i {
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      } {
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      } if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        } (x % i == 0) && (y % i == 0) (x % i == 0) x % i x i 0 (y % i == 0) y % i y i 0 {
          gcd = i;
        } gcd = i gcd i System.out.println(gcd) System.out.println System.out System System.out gcd String[] main main public class Main {
  public static void main(String[] main){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int gcd = 1;  /* gcd：最大公約数を１に初期化 */
    int small = 0;
    //x.compareTo(y);

    /* x÷y or y÷x が割り切れるとき, 小さい方を最大公約数として返す */
    if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    }
  }
} public class Main {
  public static void main(String[] main){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int gcd = 1;  /* gcd：最大公約数を１に初期化 */
    int small = 0;
    //x.compareTo(y);

    /* x÷y or y÷x が割り切れるとき, 小さい方を最大公約数として返す */
    if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    }
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] main){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
    int gcd = 1;  /* gcd：最大公約数を１に初期化 */
    int small = 0;
    //x.compareTo(y);

    /* x÷y or y÷x が割り切れるとき, 小さい方を最大公約数として返す */
    if ((x % y == 0) || (y % x == 0)){
      if (x > y || x == y) System.out.println(y);
      else System.out.println(x);
    }
    else{
      if (x > y || x == y){
        x = x % y;
        small = x;
      }
      else{
        y = y % x;
        small = y;
      }

      for (int i = 1; i <= small; i++){
        if ((x % i == 0) && (y % i == 0)){
          gcd = i;
        }
      }
      System.out.println(gcd);
    }
  }
}
