import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        } true {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        } int c = Math.max(a, b); c Math.max(a, b) Math.max Math a b int d = Math.min(a, b); d Math.min(a, b) Math.min Math a b a = c % d a c % d c d b = d b d if (a == 0) {
                System.out.println(d);
                break;
            } a == 0 a 0 {
                System.out.println(d);
                break;
            } System.out.println(d) System.out.println System.out System System.out d break; String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        while(true) {
            int c = Math.max(a, b);
            int d = Math.min(a, b);
            a = c % d;
            b = d;
            if (a == 0) {
                System.out.println(d);
                break;
            }
        }
    }
}
