import java.util.Scanner;

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

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