import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=Math.max(x,y);
		int b=Math.min(x,y);
		System.out.println(gcd(a,b));
	}
	static int gcd(int a, int b){
		int r;
		while(b>0){
			r=a%b;
			a=b;
			b=r;
		}
		return a;
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=Math.max(x,y);
		int b=Math.min(x,y);
		System.out.println(gcd(a,b));
	}
	static int gcd(int a, int b){
		int r;
		while(b>0){
			r=a%b;
			a=b;
			b=r;
		}
		return a;
	}

} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=Math.max(x,y);
		int b=Math.min(x,y);
		System.out.println(gcd(a,b));
	} main {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=Math.max(x,y);
		int b=Math.min(x,y);
		System.out.println(gcd(a,b));
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc int y=sc.nextInt(); y sc.nextInt() sc.nextInt sc int a=Math.max(x,y); a Math.max(x,y) Math.max Math x y int b=Math.min(x,y); b Math.min(x,y) Math.min Math x y System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b String[] args args static int gcd(int a, int b){
		int r;
		while(b>0){
			r=a%b;
			a=b;
			b=r;
		}
		return a;
	} gcd {
		int r;
		while(b>0){
			r=a%b;
			a=b;
			b=r;
		}
		return a;
	} int r; r while(b>0){
			r=a%b;
			a=b;
			b=r;
		} b>0 b 0 {
			r=a%b;
			a=b;
			b=r;
		} r=a%b r a%b a b a=b a b b=r b r return a; a int a a int b b public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=Math.max(x,y);
		int b=Math.min(x,y);
		System.out.println(gcd(a,b));
	}
	static int gcd(int a, int b){
		int r;
		while(b>0){
			r=a%b;
			a=b;
			b=r;
		}
		return a;
	}

} public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=Math.max(x,y);
		int b=Math.min(x,y);
		System.out.println(gcd(a,b));
	}
	static int gcd(int a, int b){
		int r;
		while(b>0){
			r=a%b;
			a=b;
			b=r;
		}
		return a;
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=Math.max(x,y);
		int b=Math.min(x,y);
		System.out.println(gcd(a,b));
	}
	static int gcd(int a, int b){
		int r;
		while(b>0){
			r=a%b;
			a=b;
			b=r;
		}
		return a;
	}

}