import java.util.Scanner;

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

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int r = 0;
    if(a<=b){
      swap(a, b);
    }
    while(b > 0){
      r = a % b;
      a = b;
      b = r;
    }
    System.out.println(a);
  }
  private static void swap(int x, int y){
    int z;
    z = x;
    x = y;
    y = z;
  }
}
