import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    }
} Main public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    } main {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    } Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int x = scn.nextInt(); x scn.nextInt() scn.nextInt scn int y = scn.nextInt(); y scn.nextInt() scn.nextInt scn int ans = 1; ans 1 while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        } true {
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        } if(x == 0) {
                ans = y;
                break;
            } x == 0 x 0 {
                ans = y;
                break;
            } ans = y ans y break; if(y == 0) {
                ans = x;
                break;
            } y == 0 y 0 {
                ans = x;
                break;
            } ans = x ans x break; if(x > y){
                x %= y;
            }
            else{
                y %= x;
            } x > y x y {
                x %= y;
            } x %= y x y {
                y %= x;
            } y %= x y x System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    }
} public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int x = scn.nextInt();
        int y = scn.nextInt();
        int ans = 1;

        while(true){
            if(x == 0) {
                ans = y;
                break;
            }
            if(y == 0) {
                ans = x;
                break;
            }

            if(x > y){
                x %= y;
            }
            else{
                y %= x;
            }
        }

        System.out.println(ans);

    }
}
