import java.util.Scanner;

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

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