x,y = map(int,input().split())

def swap(x,y):
    temp = x
    x = y
    y = temp
    return(x,y)

def gcd(x,y):
    if x < y:
        x,y= swap(x,y)

    while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
    print(x)

gcd(x,y)
 x,y = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split y def swap(x,y):
    temp = x
    x = y
    y = temp
    return(x,y) swap temp = x temp x x = y x y y = temp y temp return(x,y) (x,y) x y x x y y def gcd(x,y):
    if x < y:
        x,y= swap(x,y)

    while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
    print(x) gcd if x < y:
        x,y= swap(x,y)

     x < y x y x,y= swap(x,y) x swap(x,y) swap x y y while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
     x != y and y != 0 x != y x y y != 0 y 0 x = x%y x x%y x y x,y = swap(x,y) x swap(x,y) swap x y y print(x) print x x x y y gcd(x,y) gcd x y y = map(int,input().split()) map(int,input().split()) y x,y = map(int,input().split()) map(int,input().split()) x def gcd(x,y):
    if x < y:
        x,y= swap(x,y)

    while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
    print(x) def gcd(x,y):
    if x < y:
        x,y= swap(x,y)

    while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
    print(x) gcd def swap(x,y):
    temp = x
    x = y
    y = temp
    return(x,y) def swap(x,y):
    temp = x
    x = y
    y = temp
    return(x,y) swap
x,y = map(int,input().split())

def swap(x,y):
    temp = x
    x = y
    y = temp
    return(x,y)

def gcd(x,y):
    if x < y:
        x,y= swap(x,y)

    while(x != y and y != 0):
        x = x%y
        x,y = swap(x,y)
    print(x)

gcd(x,y)

