import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int x = Integer.parseInt(str[0]), y = Integer.parseInt(str[1]), rest;

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0);

		System.out.println(x);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int x = Integer.parseInt(str[0]), y = Integer.parseInt(str[1]), rest;

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0);

		System.out.println(x);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int x = Integer.parseInt(str[0]), y = Integer.parseInt(str[1]), rest;

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0);

		System.out.println(x);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int x = Integer.parseInt(str[0]), y = Integer.parseInt(str[1]), rest;

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0);

		System.out.println(x);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str[] = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(str[0]) x Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 y = Integer.parseInt(str[1]) y Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 rest; rest if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		} x < y x y {
			int temp = x;
			x = y;
			y = temp;
		} int temp = x; temp x x = y x y y = temp y temp do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0); y != 0 y 0 {
			rest = x % y;
			x = y;
			y = rest;
		} rest = x % y rest x % y x y x = y x y y = rest y rest System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int x = Integer.parseInt(str[0]), y = Integer.parseInt(str[1]), rest;

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0);

		System.out.println(x);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int x = Integer.parseInt(str[0]), y = Integer.parseInt(str[1]), rest;

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0);

		System.out.println(x);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int x = Integer.parseInt(str[0]), y = Integer.parseInt(str[1]), rest;

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}

		do {
			rest = x % y;
			x = y;
			y = rest;
		} while (y != 0);

		System.out.println(x);
	}
}