import math
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a >= b:
        return gcd(b, a%b)
    else:
        return gcd(a, b%a)

a,b = map(int, input().split())
print(gcd(a,b)) import math math def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a >= b:
        return gcd(b, a%b)
    else:
        return gcd(a, b%a) gcd if a == 0:
        return b
     a == 0 a 0 return b b if b == 0:
        return a
     b == 0 b 0 return a a if a >= b:
        return gcd(b, a%b)
    else:
        return gcd(a, b%a) a >= b a b return gcd(b, a%b) gcd(b, a%b) gcd b a%b a b return gcd(a, b%a) gcd(a, b%a) gcd a b%a b a a a b b a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b print(gcd(a,b)) print gcd(a,b) gcd a b b = map(int, input().split()) map(int, input().split()) b a,b = map(int, input().split()) map(int, input().split()) a def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a >= b:
        return gcd(b, a%b)
    else:
        return gcd(a, b%a) def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a >= b:
        return gcd(b, a%b)
    else:
        return gcd(a, b%a) gcd
import math
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a >= b:
        return gcd(b, a%b)
    else:
        return gcd(a, b%a)

a,b = map(int, input().split())
print(gcd(a,b))