import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x, y;
		int max, min, mod;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		}
		
		System.out.println(x);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x, y;
		int max, min, mod;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		}
		
		System.out.println(x);
	}
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x, y;
		int max, min, mod;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		}
		
		System.out.println(x);
	} main {
		Scanner sc = new Scanner(System.in);
		int x, y;
		int max, min, mod;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		}
		
		System.out.println(x);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x x y; y int max max min min mod; mod x = sc.nextInt() x sc.nextInt() sc.nextInt sc y = sc.nextInt() y sc.nextInt() sc.nextInt sc while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		} y > 0 y 0 {
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		} max = Math.max(x, y) max Math.max(x, y) Math.max Math x y min = Math.min(x, y) min Math.min(x, y) Math.min Math x y mod = max % min mod max % min max min x = min x min y = mod y mod System.out.println(x) System.out.println System.out System System.out x String args[] args public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x, y;
		int max, min, mod;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		}
		
		System.out.println(x);
	}
} public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x, y;
		int max, min, mod;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		}
		
		System.out.println(x);
	}
} Main
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x, y;
		int max, min, mod;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		while(y > 0){
			max = Math.max(x, y);
			min = Math.min(x, y);
			mod = max % min;
			
			x = min;
			y = mod;
		}
		
		System.out.println(x);
	}
}