def GCD_calc(A,B):
    if(A>=B):
        big = A
        small = B
    else:
        big = B
        small = A
    r=big%small
    if r == 0:
        return small
    else:
        return GCD_calc(small,r)

a,b = map(int,input().split())
print(GCD_calc(a,b))
 def GCD_calc(A,B):
    if(A>=B):
        big = A
        small = B
    else:
        big = B
        small = A
    r=big%small
    if r == 0:
        return small
    else:
        return GCD_calc(small,r) GCD_calc if(A>=B):
        big = A
        small = B
    else:
        big = B
        small = A
     A>=B A B big = A big A small = B small B big = B big B small = A small A r=big%small r big%small big small if r == 0:
        return small
    else:
        return GCD_calc(small,r) r == 0 r 0 return small small return GCD_calc(small,r) GCD_calc(small,r) GCD_calc small r A A B B a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b print(GCD_calc(a,b)) print GCD_calc(a,b) GCD_calc a b a,b = map(int,input().split()) map(int,input().split()) a b = map(int,input().split()) map(int,input().split()) b def GCD_calc(A,B):
    if(A>=B):
        big = A
        small = B
    else:
        big = B
        small = A
    r=big%small
    if r == 0:
        return small
    else:
        return GCD_calc(small,r) def GCD_calc(A,B):
    if(A>=B):
        big = A
        small = B
    else:
        big = B
        small = A
    r=big%small
    if r == 0:
        return small
    else:
        return GCD_calc(small,r) GCD_calc
def GCD_calc(A,B):
    if(A>=B):
        big = A
        small = B
    else:
        big = B
        small = A
    r=big%small
    if r == 0:
        return small
    else:
        return GCD_calc(small,r)

a,b = map(int,input().split())
print(GCD_calc(a,b))

