import java.util.Scanner;

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

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

