def g(n):

 x,y=n

 r=x%y

 if r>0:g((y,r))

 else:print(y)

g(sorted(list(map(int,input().split()))))
import math

a,b=list(map(int,input().split()))

print((math.gcd(a,b)))



'''

# 09.98 sec    13492 KB    4 lines     99 bytes

# Time Limit Exceeded

n=int(input())

r=[int(input())for _ in range(n)]

print(max([max(r[i+1:])-r[i]for i in range(n-1)]))

'''
def g(n):
    x, y = n
    r = x % y
    if r > 0:
        g((y, r))
    else:
        print(y)


g(sorted(list(map(int, input().split()))))

import math

a, b = list(map(int, input().split()))
print((math.gcd(a, b)))
"""
# 09.98 sec    13492 KB    4 lines     99 bytes
# Time Limit Exceeded
n=int(input())
r=[int(input())for _ in range(n)]
print(max([max(r[i+1:])-r[i]for i in range(n-1)]))
"""

-def g(n): -    x, y = n -    r = x % y -    if r > 0: -        g((y, r)) -    else: -        print(y) +import math - -g(sorted(list(map(int, input().split())))) +a, b = list(map(int, input().split())) +print((math.gcd(a, b))) +""" +# 09.98 sec    13492 KB    4 lines     99 bytes +# Time Limit Exceeded +n=int(input()) +r=[int(input())for _ in range(n)] +print(max([max(r[i+1:])-r[i]for i in range(n-1)])) +"""