def gcd(x,y):
    if x%y==0: return y
    else     : return gcd(y,x%y)

if __name__=='__main__':
   x,y=list(map(int,input().split())) 
   print(gcd(x,y)) def gcd(x,y):
    if x%y==0: return y
    else     : return gcd(y,x%y) gcd if x%y==0: return y
    else     : return gcd(y,x%y) x%y==0 x%y x y 0 x x y y if __name__=='__main__':
   x,y=list(map(int,input().split())) 
   print(gcd(x,y)) __name__=='__main__' __name__ '__main__' x,y=list(map(int,input().split())) x list(map(int,input().split())) list 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(x,y):
    if x%y==0: return y
    else     : return gcd(y,x%y) def gcd(x,y):
    if x%y==0: return y
    else     : return gcd(y,x%y) gcd x,y=list(map(int,input().split())) list(map(int,input().split())) x y=list(map(int,input().split())) list(map(int,input().split())) y
def gcd(x,y):
    if x%y==0: return y
    else     : return gcd(y,x%y)

if __name__=='__main__':
   x,y=list(map(int,input().split())) 
   print(gcd(x,y))