import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

class Main {
	//最大公約数を求める
	static int Gcd(int x, int y) {
		
		int n = Math.min(x, y);
		
		for (int i = n; i >= 1; i--) 
			if (x % i == 0 && y % i == 0) return i;
		
		return 1;
	}
		
	static class InputReader {
		BufferedReader br;
		StringTokenizer st;
		
		public String nextString() {
			
			 while (!st.hasMoreTokens()) {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            }
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(nextString());
		}
					
		public InputReader (InputStream inputStream) {
			br = new BufferedReader (new InputStreamReader (inputStream));
			st = new StringTokenizer ("");
		}
		
	}
	
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		InputReader in = new InputReader (inputStream);
		
		//２つの自然数入力
		int x = in.nextInt();
		int y = in.nextInt();
		
		int gcd;
		
		if ( x == y) gcd = x;
		else if (x > y) {
			int n = x % y;
			gcd = Gcd(y,n);
		} else {
			int n = y % x;
			gcd = Gcd(x,n);
		}
		
		System.out.println(gcd);
	}
	
}


/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz