import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);

        do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0);

        System.out.println(y);
    }
} import java.io.*; io.* java public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);

        do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0);

        System.out.println(y);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);

        do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0);

        System.out.println(y);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);

        do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0);

        System.out.println(y);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(line[0]); x Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int y = Integer.parseInt(line[1]); y Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0); x % y != 0 x % y x y 0 {
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        } if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            } x > y x y {
                int tmp = x;
                x = y;
                y = tmp % y;
            } int tmp = x; tmp x x = y x y y = tmp % y y tmp % y tmp y if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            } x < y x y {
                int tmp = y;
                y = x;
                x = tmp;
            } int tmp = y; tmp y y = x y x x = tmp x tmp {
                break;
            } break; System.out.println(y) System.out.println System.out System System.out y String[] args args public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);

        do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0);

        System.out.println(y);
    }
} public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);

        do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0);

        System.out.println(y);
    }
} Main
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);

        do{
            if(x > y){
                int tmp = x;
                x = y;
                y = tmp % y;
            }else if(x < y){
                int tmp = y;
                y = x;
                x = tmp;
            }else{
                break;
            }
        }while(x % y != 0);

        System.out.println(y);
    }
}