def gcd(a,b):
    if a == 0:
        return b
    else:
        g = gcd(b%a,a)
        return g

n1,n2 = map(int,raw_input().split())
print gcd(n1,n2) def gcd(a,b):
    if a == 0:
        return b
    else:
        g = gcd(b%a,a)
        return g gcd if a == 0:
        return b
    else:
        g = gcd(b%a,a)
        return g a == 0 a 0 return b b g = gcd(b%a,a) g gcd(b%a,a) gcd b%a b a a return g g a a b b n1,n2 = map(int,raw_input().split()) n1 map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split n2 print gcd(n1,n2) gcd n1 n2 n2 = map(int,raw_input().split()) map(int,raw_input().split()) n2 def gcd(a,b):
    if a == 0:
        return b
    else:
        g = gcd(b%a,a)
        return g def gcd(a,b):
    if a == 0:
        return b
    else:
        g = gcd(b%a,a)
        return g gcd n1,n2 = map(int,raw_input().split()) map(int,raw_input().split()) n1
def gcd(a,b):
    if a == 0:
        return b
    else:
        g = gcd(b%a,a)
        return g

n1,n2 = map(int,raw_input().split())
print gcd(n1,n2)