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