import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    if(x < y){
    	int tmp = x;
    	x = y;
    	y = tmp;
    }

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

    while(x % y != 0){
    	int tmp = x % y;
    	x = y;
    	y = tmp;
    }
	System.out.println(y);
    
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    if(x < y){
    	int tmp = x;
    	x = y;
    	y = tmp;
    }

    while(x % y != 0){
    	int tmp = x % y;
    	x = y;
    	y = tmp;
    }
	System.out.println(y);
    
  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    if(x < y){
    	int tmp = x;
    	x = y;
    	y = tmp;
    }

    while(x % y != 0){
    	int tmp = x % y;
    	x = y;
    	y = tmp;
    }
	System.out.println(y);
    
  } 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 if(x < y){
    	int tmp = x;
    	x = y;
    	y = tmp;
    } x < y x y {
    	int tmp = x;
    	x = y;
    	y = tmp;
    } int tmp = x; tmp x x = y x y y = tmp y tmp while(x % y != 0){
    	int tmp = x % y;
    	x = y;
    	y = tmp;
    } x % y != 0 x % y x y 0 {
    	int tmp = x % y;
    	x = y;
    	y = tmp;
    } int tmp = x % y; tmp x % y x y x = y x y y = tmp y tmp System.out.println(y) System.out.println System.out System System.out y String[] args args
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    if(x < y){
    	int tmp = x;
    	x = y;
    	y = tmp;
    }

    while(x % y != 0){
    	int tmp = x % y;
    	x = y;
    	y = tmp;
    }
	System.out.println(y);
    
  }
}