import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r;
        while(x != 0){
            r = y%x;
            y = x;
            x = r;
        }
        System.out.println(y);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r;
        while(x != 0){
            r = y%x;
            y = x;
            x = r;
        }
        System.out.println(y);
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r;
        while(x != 0){
            r = y%x;
            y = x;
            x = r;
        }
        System.out.println(y);
    } main {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r;
        while(x != 0){
            r = y%x;
            y = x;
            x = r;
        }
        System.out.println(y);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan int r; r while(x != 0){
            r = y%x;
            y = x;
            x = r;
        } x != 0 x 0 {
            r = y%x;
            y = x;
            x = r;
        } r = y%x r y%x y x y = x y x x = r x r 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){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r;
        while(x != 0){
            r = y%x;
            y = x;
            x = r;
        }
        System.out.println(y);
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r;
        while(x != 0){
            r = y%x;
            y = x;
            x = r;
        }
        System.out.println(y);
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r;
        while(x != 0){
            r = y%x;
            y = x;
            x = r;
        }
        System.out.println(y);
    }
}
