import java.util.Scanner;
class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int num1 = scan.nextInt();
    	int num2 = scan.nextInt();
    	int x;
    	int y;
    	
    	if(num1 > num2){
    		x = num1;
    		y = num2;
    	}else{
    		x = num2;
    		y = num1;
    	}
    	
    	int tmp;
    	for( ;(tmp = x % y) != 0; ){
    		x = y;
    		y = tmp;
    	}
    	
    	System.out.println(y);
     }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int num1 = scan.nextInt();
    	int num2 = scan.nextInt();
    	int x;
    	int y;
    	
    	if(num1 > num2){
    		x = num1;
    		y = num2;
    	}else{
    		x = num2;
    		y = num1;
    	}
    	
    	int tmp;
    	for( ;(tmp = x % y) != 0; ){
    		x = y;
    		y = tmp;
    	}
    	
    	System.out.println(y);
     }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int num1 = scan.nextInt();
    	int num2 = scan.nextInt();
    	int x;
    	int y;
    	
    	if(num1 > num2){
    		x = num1;
    		y = num2;
    	}else{
    		x = num2;
    		y = num1;
    	}
    	
    	int tmp;
    	for( ;(tmp = x % y) != 0; ){
    		x = y;
    		y = tmp;
    	}
    	
    	System.out.println(y);
     } main {
    	Scanner scan = new Scanner(System.in);
    	int num1 = scan.nextInt();
    	int num2 = scan.nextInt();
    	int x;
    	int y;
    	
    	if(num1 > num2){
    		x = num1;
    		y = num2;
    	}else{
    		x = num2;
    		y = num1;
    	}
    	
    	int tmp;
    	for( ;(tmp = x % y) != 0; ){
    		x = y;
    		y = tmp;
    	}
    	
    	System.out.println(y);
     } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int num1 = scan.nextInt(); num1 scan.nextInt() scan.nextInt scan int num2 = scan.nextInt(); num2 scan.nextInt() scan.nextInt scan int x; x int y; y if(num1 > num2){
    		x = num1;
    		y = num2;
    	}else{
    		x = num2;
    		y = num1;
    	} num1 > num2 num1 num2 {
    		x = num1;
    		y = num2;
    	} x = num1 x num1 y = num2 y num2 {
    		x = num2;
    		y = num1;
    	} x = num2 x num2 y = num1 y num1 int tmp; tmp for( ;(tmp = x % y) != 0; ){
    		x = y;
    		y = tmp;
    	} ; (tmp = x % y) != 0 (tmp = x % y) tmp x % y x y 0 {
    		x = y;
    		y = tmp;
    	} {
    		x = y;
    		y = tmp;
    	} 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 scan = new Scanner(System.in);
    	int num1 = scan.nextInt();
    	int num2 = scan.nextInt();
    	int x;
    	int y;
    	
    	if(num1 > num2){
    		x = num1;
    		y = num2;
    	}else{
    		x = num2;
    		y = num1;
    	}
    	
    	int tmp;
    	for( ;(tmp = x % y) != 0; ){
    		x = y;
    		y = tmp;
    	}
    	
    	System.out.println(y);
     }
}