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){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        }
        sc.close();
    }
} 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){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        }
        sc.close();
    }
} 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){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r;
        while(true){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        }
        sc.close();
    } 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){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        } true {
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        } if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            } x >= y x y {
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            } r = x % y r x % y x y if(r == 0){
                    System.out.println(y);
                    break;
                } r == 0 r 0 {
                    System.out.println(y);
                    break;
                } System.out.println(y) System.out.println System.out System System.out y break; x = y x y y = r y r {
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            } r = y % x r y % x y x if(r == 0){
                    System.out.println(x);
                    break;
                } r == 0 r 0 {
                    System.out.println(x);
                    break;
                } System.out.println(x) System.out.println System.out System System.out x break; y = x y x x = r x r sc.close() sc.close sc 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){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        }
        sc.close();
    }
} 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){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        }
        sc.close();
    }
} Main
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){
            if(x >= y){
                r = x % y;
                if(r == 0){
                    System.out.println(y);
                    break;
                }
                x = y;
                y = r;
            }else{
                r = y % x;
                if(r == 0){
                    System.out.println(x);
                    break;
                }
                y = x;
                x = r;
            }
        }
        sc.close();
    }
}
