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 class GreatestCommonDivisor {
		public void greatestcommondivisor (InputReader ir) {
			
			//２つの自然数入力
			int x = ir.nextInt();
			int y = ir.nextInt();
			
			StringBuilder sb = new StringBuilder ();		
			
			if ( x == y) sb.append(x); 
			else if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			}
			
			System.out.println(sb);
		}
		
		//最大公約数を求める
		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);
		GreatestCommonDivisor obj = new GreatestCommonDivisor ();
		obj.greatestcommondivisor (in);
	}
	
}
 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 class GreatestCommonDivisor {
		public void greatestcommondivisor (InputReader ir) {
			
			//２つの自然数入力
			int x = ir.nextInt();
			int y = ir.nextInt();
			
			StringBuilder sb = new StringBuilder ();		
			
			if ( x == y) sb.append(x); 
			else if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			}
			
			System.out.println(sb);
		}
		
		//最大公約数を求める
		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);
		GreatestCommonDivisor obj = new GreatestCommonDivisor ();
		obj.greatestcommondivisor (in);
	}
	
} Main public static void main (String[] args) {
		InputStream inputStream = System.in;
		InputReader in = new InputReader (inputStream);
		GreatestCommonDivisor obj = new GreatestCommonDivisor ();
		obj.greatestcommondivisor (in);
	} main {
		InputStream inputStream = System.in;
		InputReader in = new InputReader (inputStream);
		GreatestCommonDivisor obj = new GreatestCommonDivisor ();
		obj.greatestcommondivisor (in);
	} InputStream inputStream = System.in; inputStream System.in System System.in InputReader in = new InputReader (inputStream); in new InputReader (inputStream) GreatestCommonDivisor obj = new GreatestCommonDivisor (); obj new GreatestCommonDivisor () obj.greatestcommondivisor (in) obj.greatestcommondivisor obj in String[] args args static class GreatestCommonDivisor {
		public void greatestcommondivisor (InputReader ir) {
			
			//２つの自然数入力
			int x = ir.nextInt();
			int y = ir.nextInt();
			
			StringBuilder sb = new StringBuilder ();		
			
			if ( x == y) sb.append(x); 
			else if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			}
			
			System.out.println(sb);
		}
		
		//最大公約数を求める
		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;
		}
		
	} GreatestCommonDivisor public void greatestcommondivisor (InputReader ir) {
			
			//２つの自然数入力
			int x = ir.nextInt();
			int y = ir.nextInt();
			
			StringBuilder sb = new StringBuilder ();		
			
			if ( x == y) sb.append(x); 
			else if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			}
			
			System.out.println(sb);
		} greatestcommondivisor {
			
			//２つの自然数入力
			int x = ir.nextInt();
			int y = ir.nextInt();
			
			StringBuilder sb = new StringBuilder ();		
			
			if ( x == y) sb.append(x); 
			else if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			}
			
			System.out.println(sb);
		} int x = ir.nextInt(); x ir.nextInt() ir.nextInt ir int y = ir.nextInt(); y ir.nextInt() ir.nextInt ir StringBuilder sb = new StringBuilder (); sb new StringBuilder () if ( x == y) sb.append(x); 
			else if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			} x == y x y sb.append(x) sb.append sb x if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			} x > y x y {
				int n = x % y;
				sb.append(Gcd(y,n));
			} int n = x % y; n x % y x y sb.append(Gcd(y,n)) sb.append sb Gcd(y,n) Gcd y n {
				int n = y % x;
				sb.append(Gcd(x,n));
			} int n = y % x; n y % x y x sb.append(Gcd(x,n)) sb.append sb Gcd(x,n) Gcd x n System.out.println(sb) System.out.println System.out System System.out sb InputReader ir ir //最大公約数を求める
		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 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 class GreatestCommonDivisor {
		public void greatestcommondivisor (InputReader ir) {
			
			//２つの自然数入力
			int x = ir.nextInt();
			int y = ir.nextInt();
			
			StringBuilder sb = new StringBuilder ();		
			
			if ( x == y) sb.append(x); 
			else if (x > y) {
				int n = x % y;
				sb.append(Gcd(y,n));
			} else {
				int n = y % x;
				sb.append(Gcd(x,n));
			}
			
			System.out.println(sb);
		}
		
		//最大公約数を求める
		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);
		GreatestCommonDivisor obj = new GreatestCommonDivisor ();
		obj.greatestcommondivisor (in);
	}
	
}

