import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    }
} Main public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    } main {
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int x x y y p p q q tmp; tmp x=scan.nextInt() x scan.nextInt() scan.nextInt scan y=scan.nextInt() y scan.nextInt() scan.nextInt scan p=Math.max(x,y) p Math.max(x,y) Math.max Math x y q=Math.min(x,y) q Math.min(x,y) Math.min Math x y while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        } p%q!=0 p%q p q 0 {
            tmp=p%q;
            p=q;
            q=tmp;
        } tmp=p%q tmp p%q p q p=q p q q=tmp q tmp System.out.println(q) System.out.println System.out System System.out q String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x,y,p,q,tmp;
        x=scan.nextInt();
        y=scan.nextInt();
        
        p=Math.max(x,y);
        q=Math.min(x,y);
        while(p%q!=0){
            tmp=p%q;
            p=q;
            q=tmp;
        }
        System.out.println(q);
    }
}
