/* ALDS1_1_B */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt(str[0]);
      int y = Integer.parseInt(str[1]);

      System.out.println(GCD(x, y));

    }catch(Exception e){
      System.out.println(e);
    }
  }

  public static int GCD(int x, int y)
  {
    int gcd;
    if(x % y == 0){
      gcd = y;
    }else {
      gcd = GCD(y, (x % y));
    }

    return gcd;
  }
} import java.io.*; io.* java class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt(str[0]);
      int y = Integer.parseInt(str[1]);

      System.out.println(GCD(x, y));

    }catch(Exception e){
      System.out.println(e);
    }
  }

  public static int GCD(int x, int y)
  {
    int gcd;
    if(x % y == 0){
      gcd = y;
    }else {
      gcd = GCD(y, (x % y));
    }

    return gcd;
  }
} Main public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt(str[0]);
      int y = Integer.parseInt(str[1]);

      System.out.println(GCD(x, y));

    }catch(Exception e){
      System.out.println(e);
    }
  } main {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt(str[0]);
      int y = Integer.parseInt(str[1]);

      System.out.println(GCD(x, y));

    }catch(Exception e){
      System.out.println(e);
    }
  } try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt(str[0]);
      int y = Integer.parseInt(str[1]);

      System.out.println(GCD(x, y));

    }catch(Exception e){
      System.out.println(e);
    } catch(Exception e){
      System.out.println(e);
    } Exception e {
      System.out.println(e);
    } System.out.println(e) System.out.println System.out System System.out e {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt(str[0]);
      int y = Integer.parseInt(str[1]);

      System.out.println(GCD(x, y));

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(str[0]); x Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int y = Integer.parseInt(str[1]); y Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 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)
  {
    int gcd;
    if(x % y == 0){
      gcd = y;
    }else {
      gcd = GCD(y, (x % y));
    }

    return gcd;
  } GCD {
    int gcd;
    if(x % y == 0){
      gcd = y;
    }else {
      gcd = GCD(y, (x % y));
    }

    return gcd;
  } int gcd; gcd if(x % y == 0){
      gcd = y;
    }else {
      gcd = GCD(y, (x % y));
    } x % y == 0 x % y x y 0 {
      gcd = y;
    } gcd = y gcd y {
      gcd = GCD(y, (x % y));
    } gcd = GCD(y, (x % y)) gcd GCD(y, (x % y)) GCD y (x % y) x y return gcd; gcd int x x int y y
/* ALDS1_1_B */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] str = br.readLine().split(" ");
      int x = Integer.parseInt(str[0]);
      int y = Integer.parseInt(str[1]);

      System.out.println(GCD(x, y));

    }catch(Exception e){
      System.out.println(e);
    }
  }

  public static int GCD(int x, int y)
  {
    int gcd;
    if(x % y == 0){
      gcd = y;
    }else {
      gcd = GCD(y, (x % y));
    }

    return gcd;
  }
}