import java.util.Scanner;
import java.util.Arrays;

public class Main{
    static int gcd(int a, int b){
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{
    static int gcd(int a, int b){
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    }
} Main static int gcd(int a, int b){
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    } gcd {
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    } if(b < a){ int tmp = b; b = a; a = tmp; } b < a b a { int tmp = b; b = a; a = tmp; } int tmp = b; tmp b b = a b a a = tmp a tmp while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        } a != 0 a 0 {
            int tmp = b % a;
            b = a; a = tmp;
        } int tmp = b % a; tmp b % a b a b = a b a a = tmp a tmp return b; b int a a int b b public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    } main {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String[] args args public class Main{
    static int gcd(int a, int b){
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    }
} public class Main{
    static int gcd(int a, int b){
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    static int gcd(int a, int b){
        if(b < a){ int tmp = b; b = a; a = tmp; }
        while(a != 0){
            int tmp = b % a;
            b = a; a = tmp;
        }
        return b;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(gcd(a, b));
    }
}