import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		int z=1;
		while(z!=0){
			z=x%y;
			x=y;
			y=z;
		}
		System.out.println(x);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		int z=1;
		while(z!=0){
			z=x%y;
			x=y;
			y=z;
		}
		System.out.println(x);
	}
} Main public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		int z=1;
		while(z!=0){
			z=x%y;
			x=y;
			y=z;
		}
		System.out.println(x);
	} main {
		Scanner s=new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		int z=1;
		while(z!=0){
			z=x%y;
			x=y;
			y=z;
		}
		System.out.println(x);
	} Scanner s=new Scanner(System.in); s new Scanner(System.in) int x=s.nextInt(); x s.nextInt() s.nextInt s int y=s.nextInt(); y s.nextInt() s.nextInt s int z=1; z 1 while(z!=0){
			z=x%y;
			x=y;
			y=z;
		} z!=0 z 0 {
			z=x%y;
			x=y;
			y=z;
		} z=x%y z x%y x y x=y x y y=z y z 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){
		Scanner s=new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		int z=1;
		while(z!=0){
			z=x%y;
			x=y;
			y=z;
		}
		System.out.println(x);
	}
} public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		int z=1;
		while(z!=0){
			z=x%y;
			x=y;
			y=z;
		}
		System.out.println(x);
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		int z=1;
		while(z!=0){
			z=x%y;
			x=y;
			y=z;
		}
		System.out.println(x);
	}
}
