import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	}
	
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	}
	
} Main public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br String[] numbers = line.split(" "); numbers line.split(" ") line.split line " " int x = Integer.parseInt(numbers[0]); x Integer.parseInt(numbers[0]) Integer.parseInt Integer numbers[0] numbers 0 int y = Integer.parseInt(numbers[1]); y Integer.parseInt(numbers[1]) Integer.parseInt Integer numbers[1] numbers 1 int max = Math.max(x, y); max Math.max(x, y) Math.max Math x y int min = Math.min(x, y); min Math.min(x, y) Math.min Math x y while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		} true {
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		} if(max % min == 0){
				break;
			} max % min == 0 max % min max min 0 {
				break;
			} break; int v = min; v min min = max % min min max % min max min max = v max v System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	}
	
} public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	}
	
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	}
	
}