import sys

def gcd(a,b):
	temp = a
	if a<b:
		a=b
		b=temp
	if b==0:
		return a
	c = a%b
	return gcd(b,c)


line = sys.stdin.readline().strip().split(" ")
A = int(line[0])
B = int(line[1])

print(gcd(A,B)) import sys sys def gcd(a,b):
	temp = a
	if a<b:
		a=b
		b=temp
	if b==0:
		return a
	c = a%b
	return gcd(b,c) gcd temp = a temp a if a<b:
		a=b
		b=temp
	 a<b a b a=b a b b=temp b temp if b==0:
		return a
	 b==0 b 0 return a a c = a%b c a%b a b return gcd(b,c) gcd(b,c) gcd b c a a b b line = sys.stdin.readline().strip().split(" ") line sys.stdin.readline().strip().split(" ") sys.stdin.readline().strip().split sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip split " " A = int(line[0]) A int(line[0]) int line[0] line 0 B = int(line[1]) B int(line[1]) int line[1] line 1 print(gcd(A,B)) print gcd(A,B) gcd A B line = sys.stdin.readline().strip().split(" ") sys.stdin.readline().strip().split(" ") line def gcd(a,b):
	temp = a
	if a<b:
		a=b
		b=temp
	if b==0:
		return a
	c = a%b
	return gcd(b,c) def gcd(a,b):
	temp = a
	if a<b:
		a=b
		b=temp
	if b==0:
		return a
	c = a%b
	return gcd(b,c) gcd B = int(line[1]) int(line[1]) B A = int(line[0]) int(line[0]) A
import sys

def gcd(a,b):
	temp = a
	if a<b:
		a=b
		b=temp
	if b==0:
		return a
	c = a%b
	return gcd(b,c)


line = sys.stdin.readline().strip().split(" ")
A = int(line[0])
B = int(line[1])

print(gcd(A,B))