import java.util.Scanner;

public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    }
} Main private static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args){
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    } main {
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    } int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc int y=sc.nextInt(); y sc.nextInt() sc.nextInt sc while(y>0){
            int t=x%y;
            x=y;
            y=t;
        } y>0 y 0 {
            int t=x%y;
            x=y;
            y=t;
        } int t=x%y; t x%y x y x=y x y y=t y t System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    }
} public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    }
} Main
import java.util.Scanner;

public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    }
}