N,M= map(int,(input().split()))
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a = prime_factorize(N)
b = prime_factorize(M)
c= set(a) & set(b)
print(len(c)+1)
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1 N,M= map(int,(input().split())) N map(int,(input().split())) map int input().split() ().split () input split M """nを素因数分解""" """2以上の整数n => [[素因数, 指数], ...]の2次元リスト""" def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a prime_factorize a = [] a [] while n % 2 == 0:
        a.append(2)
        n //= 2
     n % 2 == 0 n % 2 n 2 0 a.append(2) a.append a append 2 n //= 2 n 2 f = 3 f 3 while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
     f * f <= n f * f f f n if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
     n % f == 0 n % f n f 0 a.append(f) a.append a append f n //= f n f f += 2 f 2 if n != 1:
        a.append(n)
     n != 1 n 1 a.append(n) a.append a append n return a a n n a = prime_factorize(N) a prime_factorize(N) prime_factorize N b = prime_factorize(M) b prime_factorize(M) prime_factorize M c= set(a) & set(b) c set(a) & set(b) set(a) set a set(b) set b print(len(c)+1) print len(c)+1 len(c) len c 1 a = prime_factorize(N) prime_factorize(N) a M= map(int,(input().split())) map(int,(input().split())) M def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a prime_factorize c= set(a) & set(b) set(a) & set(b) c b = prime_factorize(M) prime_factorize(M) b N,M= map(int,(input().split())) map(int,(input().split())) N
N,M= map(int,(input().split()))
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a = prime_factorize(N)
b = prime_factorize(M)
c= set(a) & set(b)
print(len(c)+1)
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1