from sys import stdin
def div(x,y):    
    if x%y==0:        
        return y    
    elif y%x==0:        
        return x 
    else:       
        if x>y:           
            return div(x%y,y)
        else:           
            return div(x,y%x) 
def main():    
    x=int(stdin.readline())  
    y=int(stdin.readline())  
    print(div(x,y))

main()

29fc45a5f667ccec2c68e797cde1fa73f1cd2348
<mask token>


def div(x, y):
    if x % y == 0:
        return y
    elif y % x == 0:
        return x
    elif x > y:
        return div(x % y, y)
    else:
        return div(x, y % x)


<mask token>

<mask token>


def div(x, y):
    if x % y == 0:
        return y
    elif y % x == 0:
        return x
    elif x > y:
        return div(x % y, y)
    else:
        return div(x, y % x)


def main():
    x = int(stdin.readline())
    y = int(stdin.readline())
    print(div(x, y))


<mask token>

<mask token>


def div(x, y):
    if x % y == 0:
        return y
    elif y % x == 0:
        return x
    elif x > y:
        return div(x % y, y)
    else:
        return div(x, y % x)


def main():
    x = int(stdin.readline())
    y = int(stdin.readline())
    print(div(x, y))


main()

from sys import stdin


def div(x, y):
    if x % y == 0:
        return y
    elif y % x == 0:
        return x
    elif x > y:
        return div(x % y, y)
    else:
        return div(x, y % x)


def main():
    x = int(stdin.readline())
    y = int(stdin.readline())
    print(div(x, y))


main()

from sys import stdin
def div(x,y):    
    if x%y==0:        
        return y    
    elif y%x==0:        
        return x 
    else:       
        if x>y:           
            return div(x%y,y)
        else:           
            return div(x,y%x) 
def main():    
    x=int(stdin.readline())  
    y=int(stdin.readline())  
    print(div(x,y))

main()
