import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r; //最大公約数
    while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    }
    System.out.println(x);
    }
}
 import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r; //最大公約数
    while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    }
    System.out.println(x);
    }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r; //最大公約数
    while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    }
    System.out.println(x);
    } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r; //最大公約数
    while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    }
    System.out.println(x);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int r; r while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    } true {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    } r=x%y r x%y x y x=y x y y=r y r if(r==0) break; r==0 r 0 break; System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r; //最大公約数
    while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    }
    System.out.println(x);
    }
} public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r; //最大公約数
    while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    }
    System.out.println(x);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r; //最大公約数
    while(true) {
        r=x%y;
        x=y;
        y=r;
        if(r==0) break;
    }
    System.out.println(x);
    }
}

