import math

def factorization(n):
    d = [1]
    i = 2
    while True:
        if i > int(math.sqrt(n)):
            break
        if n % i == 0:
            d.append(i)
            n //= i
        else:
            i += 1
    if n != 1:
        d.append(n)
    return d


def main():
    A, B = map(int, input().split())
    fa = set(factorization(A))
    fb = set(factorization(B))
    print(len(fa & fb))


if __name__ == '__main__':
    main() import math math def factorization(n):
    d = [1]
    i = 2
    while True:
        if i > int(math.sqrt(n)):
            break
        if n % i == 0:
            d.append(i)
            n //= i
        else:
            i += 1
    if n != 1:
        d.append(n)
    return d factorization d = [1] d [1] 1 i = 2 i 2 while True:
        if i > int(math.sqrt(n)):
            break
        if n % i == 0:
            d.append(i)
            n //= i
        else:
            i += 1
     True if i > int(math.sqrt(n)):
            break
         i > int(math.sqrt(n)) i int(math.sqrt(n)) int math.sqrt(n) math.sqrt math sqrt n break if n % i == 0:
            d.append(i)
            n //= i
        else:
            i += 1
     n % i == 0 n % i n i 0 d.append(i) d.append d append i n //= i n i i += 1 i 1 if n != 1:
        d.append(n)
     n != 1 n 1 d.append(n) d.append d append n return d d n n def main():
    A, B = map(int, input().split())
    fa = set(factorization(A))
    fb = set(factorization(B))
    print(len(fa & fb)) main A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B fa = set(factorization(A)) fa set(factorization(A)) set factorization(A) factorization A fb = set(factorization(B)) fb set(factorization(B)) set factorization(B) factorization B print(len(fa & fb)) print len(fa & fb) len fa & fb fa fb if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    A, B = map(int, input().split())
    fa = set(factorization(A))
    fb = set(factorization(B))
    print(len(fa & fb)) def main():
    A, B = map(int, input().split())
    fa = set(factorization(A))
    fb = set(factorization(B))
    print(len(fa & fb)) main def factorization(n):
    d = [1]
    i = 2
    while True:
        if i > int(math.sqrt(n)):
            break
        if n % i == 0:
            d.append(i)
            n //= i
        else:
            i += 1
    if n != 1:
        d.append(n)
    return d def factorization(n):
    d = [1]
    i = 2
    while True:
        if i > int(math.sqrt(n)):
            break
        if n % i == 0:
            d.append(i)
            n //= i
        else:
            i += 1
    if n != 1:
        d.append(n)
    return d factorization
import math

def factorization(n):
    d = [1]
    i = 2
    while True:
        if i > int(math.sqrt(n)):
            break
        if n % i == 0:
            d.append(i)
            n //= i
        else:
            i += 1
    if n != 1:
        d.append(n)
    return d


def main():
    A, B = map(int, input().split())
    fa = set(factorization(A))
    fb = set(factorization(B))
    print(len(fa & fb))


if __name__ == '__main__':
    main()
