/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scanner = new Scanner(System.in);
		
		long x = scanner.nextInt();
		long y = scanner.nextInt();
		
		/*
		long a;
		while (x % y != 0) {
			a = x;
			x = y;
			y = a % y;
			
		}
		System.out.println(y);
		*/
		
		long result = getGcd(x, y);
		
		System.out.println(result);
	}
	
	static long getGcd(long x, long y) {
		long a;
		//System.out.println(x + "," + y);
		// 終了条件
		if (x % y == 0) {
			return y;
		}
		// 引数を再設定
		a = x;
		x = y;
		y = a % y;
		
		// 再実行
		return getGcd(x, y);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scanner = new Scanner(System.in);
		
		long x = scanner.nextInt();
		long y = scanner.nextInt();
		
		/*
		long a;
		while (x % y != 0) {
			a = x;
			x = y;
			y = a % y;
			
		}
		System.out.println(y);
		*/
		
		long result = getGcd(x, y);
		
		System.out.println(result);
	}
	
	static long getGcd(long x, long y) {
		long a;
		//System.out.println(x + "," + y);
		// 終了条件
		if (x % y == 0) {
			return y;
		}
		// 引数を再設定
		a = x;
		x = y;
		y = a % y;
		
		// 再実行
		return getGcd(x, y);
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scanner = new Scanner(System.in);
		
		long x = scanner.nextInt();
		long y = scanner.nextInt();
		
		/*
		long a;
		while (x % y != 0) {
			a = x;
			x = y;
			y = a % y;
			
		}
		System.out.println(y);
		*/
		
		long result = getGcd(x, y);
		
		System.out.println(result);
	} main {
		Scanner scanner = new Scanner(System.in);
		
		long x = scanner.nextInt();
		long y = scanner.nextInt();
		
		/*
		long a;
		while (x % y != 0) {
			a = x;
			x = y;
			y = a % y;
			
		}
		System.out.println(y);
		*/
		
		long result = getGcd(x, y);
		
		System.out.println(result);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) long x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner long y = scanner.nextInt(); y scanner.nextInt() scanner.nextInt scanner long result = getGcd(x, y); result getGcd(x, y) getGcd x y System.out.println(result) System.out.println System.out System System.out result String[] args args static long getGcd(long x, long y) {
		long a;
		//System.out.println(x + "," + y);
		// 終了条件
		if (x % y == 0) {
			return y;
		}
		// 引数を再設定
		a = x;
		x = y;
		y = a % y;
		
		// 再実行
		return getGcd(x, y);
	} getGcd {
		long a;
		//System.out.println(x + "," + y);
		// 終了条件
		if (x % y == 0) {
			return y;
		}
		// 引数を再設定
		a = x;
		x = y;
		y = a % y;
		
		// 再実行
		return getGcd(x, y);
	} long a; a if (x % y == 0) {
			return y;
		} x % y == 0 x % y x y 0 {
			return y;
		} return y; y a = x a x x = y x y y = a % y y a % y a y return getGcd(x, y); getGcd(x, y) getGcd x y long x x long y y
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scanner = new Scanner(System.in);
		
		long x = scanner.nextInt();
		long y = scanner.nextInt();
		
		/*
		long a;
		while (x % y != 0) {
			a = x;
			x = y;
			y = a % y;
			
		}
		System.out.println(y);
		*/
		
		long result = getGcd(x, y);
		
		System.out.println(result);
	}
	
	static long getGcd(long x, long y) {
		long a;
		//System.out.println(x + "," + y);
		// 終了条件
		if (x % y == 0) {
			return y;
		}
		// 引数を再設定
		a = x;
		x = y;
		y = a % y;
		
		// 再実行
		return getGcd(x, y);
	}
}
