# -*- coding:utf-8 -*-
def gcd(n,m):
    if n < m:
        tmp = m
        m = n
        n = tmp
    while m > 0:
        r = n % m
        n = m
        m = r
    return n
    
x, y = map(int,input().split())
print(gcd(x,y)) def gcd(n,m):
    if n < m:
        tmp = m
        m = n
        n = tmp
    while m > 0:
        r = n % m
        n = m
        m = r
    return n
     gcd if n < m:
        tmp = m
        m = n
        n = tmp
     n < m n m tmp = m tmp m m = n m n n = tmp n tmp while m > 0:
        r = n % m
        n = m
        m = r
     m > 0 m 0 r = n % m r n % m n m n = m n m m = r m r return n n n n m m x, y = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split y print(gcd(x,y)) print gcd(x,y) gcd x y def gcd(n,m):
    if n < m:
        tmp = m
        m = n
        n = tmp
    while m > 0:
        r = n % m
        n = m
        m = r
    return n
     def gcd(n,m):
    if n < m:
        tmp = m
        m = n
        n = tmp
    while m > 0:
        r = n % m
        n = m
        m = r
    return n
     gcd x, y = map(int,input().split()) map(int,input().split()) x y = map(int,input().split()) map(int,input().split()) y
# -*- coding:utf-8 -*-
def gcd(n,m):
    if n < m:
        tmp = m
        m = n
        n = tmp
    while m > 0:
        r = n % m
        n = m
        m = r
    return n
    
x, y = map(int,input().split())
print(gcd(x,y))