
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	} main {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long a a b; b a = sc.nextLong() a sc.nextLong() sc.nextLong sc b = sc.nextLong() b sc.nextLong() sc.nextLong sc long tmp = 0; tmp 0 if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		} a < b a b {
			tmp = a;
			a = b;
			b = tmp;
		} tmp = a tmp a a = b a b b = tmp b tmp while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		} a % b != 0 a % b a b 0 {
			tmp = a;
			a = b;
			b = tmp % b;
		} tmp = a tmp a a = b a b b = tmp % b b tmp % b tmp b System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	}
}