import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		
		//２つの自然数入力
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		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);
		
	}
	
	//最大公約数を求める
	public 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;
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		
		//２つの自然数入力
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		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);
		
	}
	
	//最大公約数を求める
	public 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;
	}
} Main public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		
		//２つの自然数入力
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		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 {
		Scanner scan = new Scanner (System.in);
		
		//２つの自然数入力
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		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);
		
	} Scanner scan = new Scanner (System.in); scan new Scanner (System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan scan.close() scan.close scan 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 gcd x {
			if (x > y) {
				int n = x % y;
				gcd = Gcd(y,n);
			}else {
				int n = y % x;
				 gcd = Gcd(x,n);
			}
		} 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 //最大公約数を求める
	public 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;
			}
		} 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;
			} return i; i return 1; 1 int x x int y y public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		
		//２つの自然数入力
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		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);
		
	}
	
	//最大公約数を求める
	public 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;
	}
} public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		
		//２つの自然数入力
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		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);
		
	}
	
	//最大公約数を求める
	public 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;
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		
		//２つの自然数入力
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		
		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);
		
	}
	
	//最大公約数を求める
	public 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;
	}
}

