import java.util.Scanner;

public class Main {
    private static int gcd(int a, int b){
        if(b == 0) return a;
        else return gcd(b, a%b);
    }


    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int ans = gcd(a, b);
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    private static int gcd(int a, int b){
        if(b == 0) return a;
        else return gcd(b, a%b);
    }


    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int ans = gcd(a, b);
        System.out.println(ans);
    }
} Main private static int gcd(int a, int b){
        if(b == 0) return a;
        else return gcd(b, a%b);
    } gcd {
        if(b == 0) return a;
        else return gcd(b, a%b);
    } if(b == 0) return a;
        else return gcd(b, a%b); b == 0 b 0 return a; a return gcd(b, a%b); gcd(b, a%b) gcd b a%b a b int a a int b b public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int ans = gcd(a, b);
        System.out.println(ans);
    } main {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int ans = gcd(a, b);
        System.out.println(ans);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int a = input.nextInt(); a input.nextInt() input.nextInt input int b = input.nextInt(); b input.nextInt() input.nextInt input int ans = gcd(a, b); ans gcd(a, b) gcd a b System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    private static int gcd(int a, int b){
        if(b == 0) return a;
        else return gcd(b, a%b);
    }


    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int ans = gcd(a, b);
        System.out.println(ans);
    }
} public class Main {
    private static int gcd(int a, int b){
        if(b == 0) return a;
        else return gcd(b, a%b);
    }


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

public class Main {
    private static int gcd(int a, int b){
        if(b == 0) return a;
        else return gcd(b, a%b);
    }


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