import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	int a,b,hz,rem;
	Scanner scan =new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	}
	rem=a%b;
        while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	}
	System.out.println(b);
    }
}
 import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
	int a,b,hz,rem;
	Scanner scan =new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	}
	rem=a%b;
        while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	}
	System.out.println(b);
    }
} Main public static void main(String[] args){
	int a,b,hz,rem;
	Scanner scan =new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	}
	rem=a%b;
        while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	}
	System.out.println(b);
    } main {
	int a,b,hz,rem;
	Scanner scan =new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	}
	rem=a%b;
        while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	}
	System.out.println(b);
    } int a a b b hz hz rem; rem Scanner scan =new Scanner(System.in); scan new Scanner(System.in) a=scan.nextInt() a scan.nextInt() scan.nextInt scan b=scan.nextInt() b scan.nextInt() scan.nextInt scan if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	} b>a b a {
	    hz=a;
	    a=b;
	    b=hz;
	} hz=a hz a a=b a b b=hz b hz rem=a%b rem a%b a b while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	} rem!=0 rem 0 {
	    a=b;
	    b=rem;
	    rem=a%b;
	} a=b a b b=rem b rem rem=a%b rem a%b a b System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main{
    public static void main(String[] args){
	int a,b,hz,rem;
	Scanner scan =new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	}
	rem=a%b;
        while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	}
	System.out.println(b);
    }
} public class Main{
    public static void main(String[] args){
	int a,b,hz,rem;
	Scanner scan =new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	}
	rem=a%b;
        while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	}
	System.out.println(b);
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	int a,b,hz,rem;
	Scanner scan =new Scanner(System.in);
	a=scan.nextInt();
	b=scan.nextInt();
	if(b>a){
	    hz=a;
	    a=b;
	    b=hz;
	}
	rem=a%b;
        while(rem!=0){
	    a=b;
	    b=rem;
	    rem=a%b;
	}
	System.out.println(b);
    }
}

