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();
        
        while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        }
    }
} 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();
        
        while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        }
    } 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 while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        } true {
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        } int result = a % b; result a % b a b if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        } result == 0 result 0 {
            System.out.println(b);
            break;
        } System.out.println(b) System.out.println System.out System System.out b break; {
            a = b;
            b = result;
        } a = b a b b = result b result String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        }
    }
} 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();
        
        while(true){
        int result = a % b;
        if(result == 0){
            System.out.println(b);
            break;
        }else{
            a = b;
            b = result;
        }
        }
    }
}
