import java.util.Scanner;

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

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