import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();

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

        int x = sc.nextInt();
        int y = sc.nextInt();

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

        int x = sc.nextInt();
        int y = sc.nextInt();

        int rest;
        while(true){
            rest = x % y;
            if(rest == 0){
                System.out.println(y);
                break;
            }
            x = y;
            y = rest;
        }
        
    } main {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();

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

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();

        int rest;
        while(true){
            rest = x % y;
            if(rest == 0){
                System.out.println(y);
                break;
            }
            x = y;
            y = rest;
        }
        
    }
}
