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();
		int gcd = 1, n;
		scan.close();
		
		if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			}
		}
		
		System.out.println(gcd);
		
	}
	
	public static int Gcd(int a, int b) {
		int gcd = 1;
		int n;
		
		n = Math.min(a, b);
		
		for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		}
		
		return gcd;
	}
}
 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();
		int gcd = 1, n;
		scan.close();
		
		if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			}
		}
		
		System.out.println(gcd);
		
	}
	
	public static int Gcd(int a, int b) {
		int gcd = 1;
		int n;
		
		n = Math.min(a, b);
		
		for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		}
		
		return gcd;
	}
} Main public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd = 1, n;
		scan.close();
		
		if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				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();
		int gcd = 1, n;
		scan.close();
		
		if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				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 int gcd = 1 gcd 1 n; n scan.close() scan.close scan if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			}
		} x == y x y {
			gcd = x;
		} gcd = x gcd x {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			}
		} if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			} x > y x y {
				n = x % y;
				gcd = Gcd(y,n);
			} n = x % y n x % y x y gcd = Gcd(y,n) gcd Gcd(y,n) Gcd y n {
				n = y % x;
				gcd = Gcd(x,n);
			} 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 a, int b) {
		int gcd = 1;
		int n;
		
		n = Math.min(a, b);
		
		for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		}
		
		return gcd;
	} Gcd {
		int gcd = 1;
		int n;
		
		n = Math.min(a, b);
		
		for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		}
		
		return gcd;
	} int gcd = 1; gcd 1 int n; n n = Math.min(a, b) n Math.min(a, b) Math.min Math a b for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		} int i = n; int i = n; i n i >= 1 i 1 i-- i-- i {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		} {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		} if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			} a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
				gcd = i;
				break;
			} gcd = i gcd i break; return gcd; gcd int a a int b b public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd = 1, n;
		scan.close();
		
		if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			}
		}
		
		System.out.println(gcd);
		
	}
	
	public static int Gcd(int a, int b) {
		int gcd = 1;
		int n;
		
		n = Math.min(a, b);
		
		for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		}
		
		return gcd;
	}
} public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd = 1, n;
		scan.close();
		
		if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			}
		}
		
		System.out.println(gcd);
		
	}
	
	public static int Gcd(int a, int b) {
		int gcd = 1;
		int n;
		
		n = Math.min(a, b);
		
		for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		}
		
		return gcd;
	}
} 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();
		int gcd = 1, n;
		scan.close();
		
		if ( x == y) {
			gcd = x;
		} else {
			if (x > y) {
				n = x % y;
				gcd = Gcd(y,n);
			}else {
				n = y % x;
				gcd = Gcd(x,n);
			}
		}
		
		System.out.println(gcd);
		
	}
	
	public static int Gcd(int a, int b) {
		int gcd = 1;
		int n;
		
		n = Math.min(a, b);
		
		for (int i = n; i >= 1; i--) {
			if (a % i == 0 && b % i == 0) {
				gcd = i;
				break;
			}
			
		}
		
		return gcd;
	}
}

