# Aizu Problem ALDS_1_1_B: Greatest Common Divisor
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def gcd(a, b):
    while b != 0:
       t = b
       b = a % b
       a = t
    return a

x, y = [int(_) for _ in input().split()]
print(gcd(x, y)) import sys, math, os sys math os PYDEV = os.environ.get('PYDEV') PYDEV os.environ.get('PYDEV') os.environ.get os.environ os environ get 'PYDEV' if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt") PYDEV=="True" PYDEV "True" sys.stdin = open("sample-input2.txt", "rt") sys.stdin sys stdin open("sample-input2.txt", "rt") open "sample-input2.txt" "rt" def gcd(a, b):
    while b != 0:
       t = b
       b = a % b
       a = t
    return a gcd while b != 0:
       t = b
       b = a % b
       a = t
     b != 0 b 0 t = b t b b = a % b b a % b a b a = t a t return a a a a b b int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ x, y = [int(_) for _ in input().split()] x [int(_) for _ in input().split()] y print(gcd(x, y)) print gcd(x, y) gcd x y y = [int(_) for _ in input().split()] [int(_) for _ in input().split()] y x, y = [int(_) for _ in input().split()] [int(_) for _ in input().split()] x PYDEV = os.environ.get('PYDEV') os.environ.get('PYDEV') PYDEV def gcd(a, b):
    while b != 0:
       t = b
       b = a % b
       a = t
    return a def gcd(a, b):
    while b != 0:
       t = b
       b = a % b
       a = t
    return a gcd
# Aizu Problem ALDS_1_1_B: Greatest Common Divisor
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def gcd(a, b):
    while b != 0:
       t = b
       b = a % b
       a = t
    return a

x, y = [int(_) for _ in input().split()]
print(gcd(x, y))