def euclideanAlg(n, m):
    r = n % m
    if r == 0:
        return m
    else:
        return euclideanAlg(m, r)

if __name__ == "__main__":
    A = map(int, raw_input().split())
    print euclideanAlg(A[0], A[1]) def euclideanAlg(n, m):
    r = n % m
    if r == 0:
        return m
    else:
        return euclideanAlg(m, r) euclideanAlg r = n % m r n % m n m if r == 0:
        return m
    else:
        return euclideanAlg(m, r) r == 0 r 0 return m m return euclideanAlg(m, r) euclideanAlg(m, r) euclideanAlg m r n n m m if __name__ == "__main__":
    A = map(int, raw_input().split())
    print euclideanAlg(A[0], A[1]) __name__ == "__main__" __name__ "__main__" A = map(int, raw_input().split()) A map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split print euclideanAlg(A[0], A[1]) euclideanAlg A[0] A 0 A[1] A 1 def euclideanAlg(n, m):
    r = n % m
    if r == 0:
        return m
    else:
        return euclideanAlg(m, r) def euclideanAlg(n, m):
    r = n % m
    if r == 0:
        return m
    else:
        return euclideanAlg(m, r) euclideanAlg A = map(int, raw_input().split()) map(int, raw_input().split()) A
def euclideanAlg(n, m):
    r = n % m
    if r == 0:
        return m
    else:
        return euclideanAlg(m, r)

if __name__ == "__main__":
    A = map(int, raw_input().split())
    print euclideanAlg(A[0], A[1])