def gdc(a,b):
    #print("%d, %d"%(a,b))
    if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
        
a = [int(s) for s in input().split(" ")]
print(gdc(a[0],a[1])) def gdc(a,b):
    #print("%d, %d"%(a,b))
    if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
         gdc if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
         min(a,b) == 0 min(a,b) min a b 0 return a a return gdc(min(a,b), max(a,b)%min(a,b)) gdc(min(a,b), max(a,b)%min(a,b)) gdc min(a,b) min a b max(a,b)%min(a,b) max(a,b) max a b min(a,b) min a b a a b b int(s) for s in input().split(" ") for s in input().split(" ") s input().split(" ") ().split () input split " " for s in input().split(" ") int(s) int s a = [int(s) for s in input().split(" ")] a [int(s) for s in input().split(" ")] print(gdc(a[0],a[1])) print gdc(a[0],a[1]) gdc a[0] a 0 a[1] a 1 def gdc(a,b):
    #print("%d, %d"%(a,b))
    if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
         def gdc(a,b):
    #print("%d, %d"%(a,b))
    if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
         gdc a = [int(s) for s in input().split(" ")] [int(s) for s in input().split(" ")] a
def gdc(a,b):
    #print("%d, %d"%(a,b))
    if min(a,b) == 0:
        return a
    else:
        return gdc(min(a,b), max(a,b)%min(a,b))
        
a = [int(s) for s in input().split(" ")]
print(gdc(a[0],a[1]))