import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

} Main public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	} main {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	} Scanner sc = null; sc null try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		} catch (Exception e) {
			System.out.println(e);
		} Exception e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e {
			if (sc != null) {
				sc.close();
			}
		} if (sc != null) {
				sc.close();
			} sc != null sc null {
				sc.close();
			} sc.close() sc.close sc {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		} sc = new Scanner(System.in) sc new Scanner(System.in) int numX = sc.nextInt(); numX sc.nextInt() sc.nextInt sc int numY = sc.nextInt(); numY sc.nextInt() sc.nextInt sc int output = 0; output 0 int checkNum = 0; checkNum 0 do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0); checkNum != 0 checkNum 0 {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				} numX >= numY numX numY {
					checkNum = numX % numY;
					numX = checkNum;
				} checkNum = numX % numY checkNum numX % numY numX numY numX = checkNum numX checkNum {
					checkNum = numY % numX;
					numY = checkNum;
				} checkNum = numY % numX checkNum numY % numX numY numX numY = checkNum numY checkNum output = Math.max(numX, numY) output Math.max(numX, numY) Math.max Math numX numY System.out.println(output) System.out.println System.out System System.out output String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//2???????????¶??°???????????????
			int numX = sc.nextInt();
			int numY = sc.nextInt();

			//0??????????????§??????????±???????
			int output = 0;
			int checkNum = 0;
			do {
				//??°????????????
				if (numX >= numY) {
					checkNum = numX % numY;
					numX = checkNum;
				}else{
					checkNum = numY % numX;
					numY = checkNum;
				}
			} while (checkNum != 0);
			//???????????????
			output = Math.max(numX, numY);
			System.out.println(output);
		}catch (Exception e) {
			System.out.println(e);
		} finally {
			if (sc != null) {
				sc.close();
			}
		}
	}

}