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

class Main {

	public static void main(String[] args) throws IOException {

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n = br.readLine().split(" ");

		System.out.println(new BigInteger(n[0]).gcd(new BigInteger(n[1])));

	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.math.BigInteger; BigInteger java.math class Main {

	public static void main(String[] args) throws IOException {

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n = br.readLine().split(" ");

		System.out.println(new BigInteger(n[0]).gcd(new BigInteger(n[1])));

	}

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

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n = br.readLine().split(" ");

		System.out.println(new BigInteger(n[0]).gcd(new BigInteger(n[1])));

	} main {

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n = br.readLine().split(" ");

		System.out.println(new BigInteger(n[0]).gcd(new BigInteger(n[1])));

	} StringBuilder buider = new StringBuilder(); buider new StringBuilder() BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] n = br.readLine().split(" "); n br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " System.out.println(new BigInteger(n[0]).gcd(new BigInteger(n[1]))) System.out.println System.out System System.out new BigInteger(n[0]).gcd(new BigInteger(n[1])) new BigInteger(n[0]).gcd new BigInteger(n[0]) new BigInteger(n[1]) String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main {

	public static void main(String[] args) throws IOException {

		StringBuilder buider = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n = br.readLine().split(" ");

		System.out.println(new BigInteger(n[0]).gcd(new BigInteger(n[1])));

	}

}