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);
	}
	
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.InputMismatchException; InputMismatchException java.util import java.util.StringTokenizer; StringTokenizer java.util 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);
	}
	
} 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;
	} Gcd {
		
		int n = Math.min(x, y);
		
		for (int i = n; i >= 1; i--) 
			if (x % i == 0 && y % i == 0) return i;
		
		return 1;
	} int n = Math.min(x, y); n Math.min(x, y) Math.min Math x y for (int i = n; i >= 1; i--) 
			if (x % i == 0 && y % i == 0) return i; int i = n; int i = n; i n i >= 1 i 1 i-- i-- i if (x % i == 0 && y % i == 0) return i; if (x % i == 0 && y % i == 0) return i; x % i == 0 && y % i == 0 x % i == 0 x % i x i 0 y % i == 0 y % i y i 0 return i; i return 1; 1 int x x int y y 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);
	} main {
		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);
	} InputStream inputStream = System.in; inputStream System.in System System.in InputReader in = new InputReader (inputStream); in new InputReader (inputStream) int x = in.nextInt(); x in.nextInt() in.nextInt in int y = in.nextInt(); y in.nextInt() in.nextInt in int gcd; 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);
		} x == y x y gcd = x gcd x if (x > y) {
			int n = x % y;
			gcd = Gcd(y,n);
		} else {
			int n = y % x;
			gcd = Gcd(x,n);
		} x > y x y {
			int n = x % y;
			gcd = Gcd(y,n);
		} int n = x % y; n x % y x y gcd = Gcd(y,n) gcd Gcd(y,n) Gcd y n {
			int n = y % x;
			gcd = Gcd(x,n);
		} int n = y % x; n y % x y x gcd = Gcd(x,n) gcd Gcd(x,n) Gcd x n System.out.println(gcd) System.out.println System.out System System.out gcd String[] args args 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 ("");
		}
		
	} InputReader BufferedReader br; br StringTokenizer st; st public String nextString() {
			
			 while (!st.hasMoreTokens()) {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            }
			return st.nextToken();
		} nextString {
			
			 while (!st.hasMoreTokens()) {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            }
			return st.nextToken();
		} while (!st.hasMoreTokens()) {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            } !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            } try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                } IOException e {
	                    throw new InputMismatchException();
	                } throw new InputMismatchException(); new InputMismatchException() {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } st = new StringTokenizer(br.readLine(), " ") st new StringTokenizer(br.readLine(), " ") return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() {
			return Integer.parseInt(nextString());
		} nextInt {
			return Integer.parseInt(nextString());
		} return Integer.parseInt(nextString()); Integer.parseInt(nextString()) Integer.parseInt Integer nextString() nextString public InputReader (InputStream inputStream) {
			br = new BufferedReader (new InputStreamReader (inputStream));
			st = new StringTokenizer ("");
		} InputReader {
			br = new BufferedReader (new InputStreamReader (inputStream));
			st = new StringTokenizer ("");
		} br = new BufferedReader (new InputStreamReader (inputStream)) br new BufferedReader (new InputStreamReader (inputStream)) st = new StringTokenizer ("") st new StringTokenizer ("") InputStream inputStream inputStream
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);
	}
	
}

