import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    } main {
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int m =sc.nextInt(); m sc.nextInt() sc.nextInt sc int r; r for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        } ; {
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        } {
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        } r=n%m r n%m n m if(r==0){
            	System.out.println(m);
            	break;
            } r==0 r 0 {
            	System.out.println(m);
            	break;
            } System.out.println(m) System.out.println System.out System System.out m break; n=m n m m=r m r String[] args args public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    }
} public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n=sc.nextInt();
        int m =sc.nextInt();
        int r;
        for(;;){
            r=n%m;
            if(r==0){
            	System.out.println(m);
            	break;
            }
            n=m;
            m=r;
        }

    }
}
