def gcd(x, y):
    if x == y:
        return x
    while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
            
x, y = map(int, raw_input().split())

print gcd(x, y) def gcd(x, y):
    if x == y:
        return x
    while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
             gcd if x == y:
        return x
     x == y x y return x x while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
             1 if x < y:
            temp = x
            x = y
            y = temp
         x < y x y temp = x temp x x = y x y y = temp y temp x = x%y x x%y x y if x == 0:
            return y
             x == 0 x 0 return y y x x y y x, y = map(int, raw_input().split()) x map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split y print gcd(x, y) gcd x y x, y = map(int, raw_input().split()) map(int, raw_input().split()) x def gcd(x, y):
    if x == y:
        return x
    while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
             def gcd(x, y):
    if x == y:
        return x
    while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
             gcd y = map(int, raw_input().split()) map(int, raw_input().split()) y
def gcd(x, y):
    if x == y:
        return x
    while(1):
        if x < y:
            temp = x
            x = y
            y = temp
        x = x%y
        if x == 0:
            return y
            
x, y = map(int, raw_input().split())

print gcd(x, y)