import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    }
} Main public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    } main {
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] arr = line.split(" "); arr line.split(" ") line.split line " " int a = Integer.parseInt(arr[0]); a Integer.parseInt(arr[0]) Integer.parseInt Integer arr[0] arr 0 int b = Integer.parseInt(arr[1]); b Integer.parseInt(arr[1]) Integer.parseInt Integer arr[1] arr 1 int x; x int y; y if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        } a > b a b {
            x = a;
            y = b;
        } x = a x a y = b y b {
            x = b;
            y = a;
        } x = b x b y = a y a int c; c while((c = x % y) != 0){
            x = y;
            y = c;
        } (c = x % y) != 0 (c = x % y) c x % y x y 0 {
            x = y;
            y = c;
        } x = y x y y = c y c System.out.println(y) System.out.println System.out System System.out y sc.close() sc.close sc String[] arg arg public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    }
} public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] arr = line.split(" ");

        // String型をint型に変換
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);

        int x;
        int y;

        if(a > b){
            x = a;
            y = b;
        } else{
            x = b;
            y = a;
        }

        // ユークリッドの互除法
        int c;
        while((c = x % y) != 0){
            x = y;
            y = c;
        }

        System.out.println(y);
        sc.close();

    }
}
