import java.util.*; 

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x,y;
        int t;
        int num;
        x = stdIn.nextInt();
        y = stdIn.nextInt();

        if(x>y){
            t=y;
            y=x;
            x=t;
        }

        num = x%y;
        while(num!=0){
            x = num;
            if(y>x){
                t=x;
                x=y;
                y=t;
            }
            if(x%y==0){
                break;
            }
            num = x%y;
        }
        System.out.println(y);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x,y;
        int t;
        int num;
        x = stdIn.nextInt();
        y = stdIn.nextInt();

        if(x>y){
            t=y;
            y=x;
            x=t;
        }

        num = x%y;
        while(num!=0){
            x = num;
            if(y>x){
                t=x;
                x=y;
                y=t;
            }
            if(x%y==0){
                break;
            }
            num = x%y;
        }
        System.out.println(y);
    }
} Main public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x,y;
        int t;
        int num;
        x = stdIn.nextInt();
        y = stdIn.nextInt();

        if(x>y){
            t=y;
            y=x;
            x=t;
        }

        num = x%y;
        while(num!=0){
            x = num;
            if(y>x){
                t=x;
                x=y;
                y=t;
            }
            if(x%y==0){
                break;
            }
            num = x%y;
        }
        System.out.println(y);
    } main {
        Scanner stdIn = new Scanner(System.in);
        int x,y;
        int t;
        int num;
        x = stdIn.nextInt();
        y = stdIn.nextInt();

        if(x>y){
            t=y;
            y=x;
            x=t;
        }

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

        if(x>y){
            t=y;
            y=x;
            x=t;
        }

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

        if(x>y){
            t=y;
            y=x;
            x=t;
        }

        num = x%y;
        while(num!=0){
            x = num;
            if(y>x){
                t=x;
                x=y;
                y=t;
            }
            if(x%y==0){
                break;
            }
            num = x%y;
        }
        System.out.println(y);
    }
} Main
import java.util.*; 

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x,y;
        int t;
        int num;
        x = stdIn.nextInt();
        y = stdIn.nextInt();

        if(x>y){
            t=y;
            y=x;
            x=t;
        }

        num = x%y;
        while(num!=0){
            x = num;
            if(y>x){
                t=x;
                x=y;
                y=t;
            }
            if(x%y==0){
                break;
            }
            num = x%y;
        }
        System.out.println(y);
    }
}
