import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    } main {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) boolean bl = true; bl true int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int z; z while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        } true {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        } z = x % y z x % y x y x = y x y y = z y z if( y == 0){
                break;
            } y == 0 y 0 {
                break;
            } break; System.out.printf("%d%n", x) System.out.printf System.out System System.out "%d%n" x String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean bl = true;
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z;
        while(true) {
            z = x % y;
            x = y;
            y = z;
            if( y == 0){
                break;
            }
        }
        System.out.printf("%d%n", x);
    }
}
