import java.util.Scanner;


class Main {
    static int gcd (int x, int y) {
        int temp;
        while((temp = x%y)!=0) {
            x = y;
            y = temp;
        }
        return y;
    }

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

    System.out.println(gcd(x,y));

    stdIn.close();
    }


} import java.util.Scanner; Scanner java.util class Main {
    static int gcd (int x, int y) {
        int temp;
        while((temp = x%y)!=0) {
            x = y;
            y = temp;
        }
        return y;
    }

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

    System.out.println(gcd(x,y));

    stdIn.close();
    }


} Main static int gcd (int x, int y) {
        int temp;
        while((temp = x%y)!=0) {
            x = y;
            y = temp;
        }
        return y;
    } gcd {
        int temp;
        while((temp = x%y)!=0) {
            x = y;
            y = temp;
        }
        return y;
    } int temp; temp while((temp = x%y)!=0) {
            x = y;
            y = temp;
        } (temp = x%y)!=0 (temp = x%y) temp x%y x y 0 {
            x = y;
            y = temp;
        } x = y x y y = temp y temp return y; y int x x int y y public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();
    int z;
    if(x<y){
        z = x;
        x = y;
        y = z;
    }

    System.out.println(gcd(x,y));

    stdIn.close();
    } main {
    Scanner stdIn = new Scanner(System.in);
    
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();
    int z;
    if(x<y){
        z = x;
        x = y;
        y = z;
    }

    System.out.println(gcd(x,y));

    stdIn.close();
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int x = stdIn.nextInt(); x stdIn.nextInt() stdIn.nextInt stdIn int y = stdIn.nextInt(); y stdIn.nextInt() stdIn.nextInt stdIn int z; z if(x<y){
        z = x;
        x = y;
        y = z;
    } x<y x y {
        z = x;
        x = y;
        y = z;
    } z = x z x x = y x y y = z y z System.out.println(gcd(x,y)) System.out.println System.out System System.out gcd(x,y) gcd x y stdIn.close() stdIn.close stdIn String[] args args
import java.util.Scanner;


class Main {
    static int gcd (int x, int y) {
        int temp;
        while((temp = x%y)!=0) {
            x = y;
            y = temp;
        }
        return y;
    }

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

    System.out.println(gcd(x,y));

    stdIn.close();
    }


}
