import java.util.Scanner;

public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	}

	public static int calculation(int x, int y, int gcd) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	}
}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	}

	public static int calculation(int x, int y, int gcd) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	}
} Main public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int gcd = 0; gcd 0 if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		} x == y x y {
			gcd = x;
		} gcd = x gcd x {
			gcd = calculation(x, y, gcd);
		} gcd = calculation(x, y, gcd) gcd calculation(x, y, gcd) calculation x y gcd System.out.println(gcd) System.out.println System.out System System.out gcd sc.close() sc.close sc String[] atgs atgs public static int calculation(int x, int y, int gcd) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	} calculation {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	} if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		} x < y x y {
			int tmp = x;
			x = y;
			y = tmp;
		} int tmp = x; tmp x x = y x y y = tmp y tmp x %= y x y for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		} int i = x; int i = x; i x true i-- i-- i {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		} {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		} if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			} x % i == 0 && y % i == 0 x % i == 0 x % i x i 0 y % i == 0 y % i y i 0 {
				gcd = i;
				break;
			} gcd = i gcd i break; return gcd; gcd int x x int y y int gcd gcd public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	}

	public static int calculation(int x, int y, int gcd) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	}
} public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	}

	public static int calculation(int x, int y, int gcd) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	}

	public static int calculation(int x, int y, int gcd) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	}
}

