import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int a = Integer.parseInt(std.next());
		int b = Integer.parseInt(std.next());
		int temp;
		if(a<b){temp=b; b=a; a=temp;}

		int m = a%b;
		while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		}
		System.out.println(b);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int a = Integer.parseInt(std.next());
		int b = Integer.parseInt(std.next());
		int temp;
		if(a<b){temp=b; b=a; a=temp;}

		int m = a%b;
		while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		}
		System.out.println(b);
	}
} Main public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int a = Integer.parseInt(std.next());
		int b = Integer.parseInt(std.next());
		int temp;
		if(a<b){temp=b; b=a; a=temp;}

		int m = a%b;
		while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		}
		System.out.println(b);
	} main {
		Scanner std = new Scanner(System.in);
		int a = Integer.parseInt(std.next());
		int b = Integer.parseInt(std.next());
		int temp;
		if(a<b){temp=b; b=a; a=temp;}

		int m = a%b;
		while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		}
		System.out.println(b);
	} Scanner std = new Scanner(System.in); std new Scanner(System.in) int a = Integer.parseInt(std.next()); a Integer.parseInt(std.next()) Integer.parseInt Integer std.next() std.next std int b = Integer.parseInt(std.next()); b Integer.parseInt(std.next()) Integer.parseInt Integer std.next() std.next std int temp; temp if(a<b){temp=b; b=a; a=temp;} a<b a b {temp=b; b=a; a=temp;} temp=b temp b b=a b a a=temp a temp int m = a%b; m a%b a b while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		} m!=0 m 0 {
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		} temp = a temp a a = b a b b = temp%b b temp%b temp b m = a%b m 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){
		Scanner std = new Scanner(System.in);
		int a = Integer.parseInt(std.next());
		int b = Integer.parseInt(std.next());
		int temp;
		if(a<b){temp=b; b=a; a=temp;}

		int m = a%b;
		while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		}
		System.out.println(b);
	}
} public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int a = Integer.parseInt(std.next());
		int b = Integer.parseInt(std.next());
		int temp;
		if(a<b){temp=b; b=a; a=temp;}

		int m = a%b;
		while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		}
		System.out.println(b);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int a = Integer.parseInt(std.next());
		int b = Integer.parseInt(std.next());
		int temp;
		if(a<b){temp=b; b=a; a=temp;}

		int m = a%b;
		while(m!=0){
			temp = a;
			a = b;
			b = temp%b;
			m = a%b;
		}
		System.out.println(b);
	}
}