def gcm(a, b):

    if a % b == 0:
        return b
    else:
        return gcm(b, a % b)


if __name__ == '__main__':

    [a, b] = [int(x) for x in input().split()]

    print(gcm(a,b)) def gcm(a, b):

    if a % b == 0:
        return b
    else:
        return gcm(b, a % b) gcm if a % b == 0:
        return b
    else:
        return gcm(b, a % b) a % b == 0 a % b a b 0 return b b return gcm(b, a % b) gcm(b, a % b) gcm b a % b a b a a b b if __name__ == '__main__':

    [a, b] = [int(x) for x in input().split()]

    print(gcm(a,b)) __name__ == '__main__' __name__ '__main__' int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x [a, b] = [int(x) for x in input().split()] [a, b] a b [int(x) for x in input().split()] print(gcm(a,b)) print gcm(a,b) gcm a b def gcm(a, b):

    if a % b == 0:
        return b
    else:
        return gcm(b, a % b) def gcm(a, b):

    if a % b == 0:
        return b
    else:
        return gcm(b, a % b) gcm
def gcm(a, b):

    if a % b == 0:
        return b
    else:
        return gcm(b, a % b)


if __name__ == '__main__':

    [a, b] = [int(x) for x in input().split()]

    print(gcm(a,b))
