import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int i,j,k,x,y,d,ax,ay,G=0,a=0,b=0,yy;
		Scanner sc=new Scanner(System.in);
		x=Integer.parseInt(sc.next());
		y=Integer.parseInt(sc.next());
		
		if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		}
		while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		}
		
		
		System.out.println(x);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		int i,j,k,x,y,d,ax,ay,G=0,a=0,b=0,yy;
		Scanner sc=new Scanner(System.in);
		x=Integer.parseInt(sc.next());
		y=Integer.parseInt(sc.next());
		
		if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		}
		while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		}
		
		
		System.out.println(x);
	}

} Main public static void main(String[] args) {
		int i,j,k,x,y,d,ax,ay,G=0,a=0,b=0,yy;
		Scanner sc=new Scanner(System.in);
		x=Integer.parseInt(sc.next());
		y=Integer.parseInt(sc.next());
		
		if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		}
		while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		}
		
		
		System.out.println(x);
	} main {
		int i,j,k,x,y,d,ax,ay,G=0,a=0,b=0,yy;
		Scanner sc=new Scanner(System.in);
		x=Integer.parseInt(sc.next());
		y=Integer.parseInt(sc.next());
		
		if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		}
		while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		}
		
		
		System.out.println(x);
	} int i i j j k k x x y y d d ax ax ay ay G=0 G 0 a=0 a 0 b=0 b 0 yy; yy Scanner sc=new Scanner(System.in); sc new Scanner(System.in) x=Integer.parseInt(sc.next()) x Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc y=Integer.parseInt(sc.next()) y Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		} x<y x y {
		
		a=x;
		b=y;
		x=b;
		y=a;
		} a=x a x b=y b y x=b x b y=a y a while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		} y>0 y 0 {
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		} a=y a y b=x%y b x%y x y y=b y b x=a x a System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {

	public static void main(String[] args) {
		int i,j,k,x,y,d,ax,ay,G=0,a=0,b=0,yy;
		Scanner sc=new Scanner(System.in);
		x=Integer.parseInt(sc.next());
		y=Integer.parseInt(sc.next());
		
		if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		}
		while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		}
		
		
		System.out.println(x);
	}

} public class Main {

	public static void main(String[] args) {
		int i,j,k,x,y,d,ax,ay,G=0,a=0,b=0,yy;
		Scanner sc=new Scanner(System.in);
		x=Integer.parseInt(sc.next());
		y=Integer.parseInt(sc.next());
		
		if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		}
		while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		}
		
		
		System.out.println(x);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int i,j,k,x,y,d,ax,ay,G=0,a=0,b=0,yy;
		Scanner sc=new Scanner(System.in);
		x=Integer.parseInt(sc.next());
		y=Integer.parseInt(sc.next());
		
		if(x<y){
		
		a=x;
		b=y;
		x=b;
		y=a;
		}
		while(y>0){
		a=y;
		b=x%y;
	
		y=b;
		x=a;
		
		}
		
		
		System.out.println(x);
	}

}