import java.util.Scanner;

public class Main
{
    public static int gcd(int x, int y) {
        int max, min, temp;
        if(x > y){
            max = x;
            min = y;
        } else {
            max = y;
            min = x;
        }
        
        while(true){
            if(max % min == 0){
                return min;
            } else {
                temp = max % min;
                max = min;
                min = temp;
            }
        }
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x, y));
    }
}
 import java.util.Scanner; Scanner java.util public class Main
{
    public static int gcd(int x, int y) {
        int max, min, temp;
        if(x > y){
            max = x;
            min = y;
        } else {
            max = y;
            min = x;
        }
        
        while(true){
            if(max % min == 0){
                return min;
            } else {
                temp = max % min;
                max = min;
                min = temp;
            }
        }
    }

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

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x, y));
    }
} public class Main
{
    public static int gcd(int x, int y) {
        int max, min, temp;
        if(x > y){
            max = x;
            min = y;
        } else {
            max = y;
            min = x;
        }
        
        while(true){
            if(max % min == 0){
                return min;
            } else {
                temp = max % min;
                max = min;
                min = temp;
            }
        }
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x, y));
    }
} Main
import java.util.Scanner;

public class Main
{
    public static int gcd(int x, int y) {
        int max, min, temp;
        if(x > y){
            max = x;
            min = y;
        } else {
            max = y;
            min = x;
        }
        
        while(true){
            if(max % min == 0){
                return min;
            } else {
                temp = max % min;
                max = min;
                min = temp;
            }
        }
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x, y));
    }
}

