def is_prime(n):
    if n == 2 or n == 3: return True
    if n < 2 or n%2 == 0: return False
    if n < 9: return True
    if n%3 == 0: return False
    r = int(n**0.5)
    f = 5
    while f <= r:
        if n%f == 0: return False
        if n%(f+2) == 0: return False
        f +=6
    return True  

def divisors(n):
    lower_divs , upper_divs = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs + upper_divs[::-1]

def resolve():
    A, B = list(map(int, input().split()))
    divs = divisors(A)
    i = 1
    cnt = 0
    while i < len(divs):
        if B%divs[i]==0 and is_prime(divs[i]):
            cnt += 1
        i += 1
    print(cnt+1)
    

if '__main__' == __name__:
    resolve() def is_prime(n):
    if n == 2 or n == 3: return True
    if n < 2 or n%2 == 0: return False
    if n < 9: return True
    if n%3 == 0: return False
    r = int(n**0.5)
    f = 5
    while f <= r:
        if n%f == 0: return False
        if n%(f+2) == 0: return False
        f +=6
    return True   is_prime if n == 2 or n == 3: return True
     n == 2 or n == 3 n == 2 n 2 n == 3 n 3 if n < 2 or n%2 == 0: return False
     n < 2 or n%2 == 0 n < 2 n 2 n%2 == 0 n%2 n 2 0 if n < 9: return True
     n < 9 n 9 if n%3 == 0: return False
     n%3 == 0 n%3 n 3 0 r = int(n**0.5) r int(n**0.5) int n**0.5 n 0.5 f = 5 f 5 while f <= r:
        if n%f == 0: return False
        if n%(f+2) == 0: return False
        f +=6
     f <= r f r if n%f == 0: return False
         n%f == 0 n%f n f 0 if n%(f+2) == 0: return False
         n%(f+2) == 0 n%(f+2) n f+2 f 2 0 f +=6 f 6 return True True n n def divisors(n):
    lower_divs , upper_divs = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs + upper_divs[::-1] divisors lower_divs , upper_divs = [], [] lower_divs [] upper_divs [] i = 1 i 1 while i*i <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
     i*i <= n i*i i i n if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
         n % i == 0 n % i n i 0 lower_divs.append(i) lower_divs.append lower_divs append i if i != n // i:
                upper_divs.append(n//i)
         i != n // i i n // i n i upper_divs.append(n//i) upper_divs.append upper_divs append n//i n i i += 1 i 1 return lower_divs + upper_divs[::-1] lower_divs + upper_divs[::-1] lower_divs upper_divs[::-1] upper_divs ::-1 -1 n n def resolve():
    A, B = list(map(int, input().split()))
    divs = divisors(A)
    i = 1
    cnt = 0
    while i < len(divs):
        if B%divs[i]==0 and is_prime(divs[i]):
            cnt += 1
        i += 1
    print(cnt+1)
     resolve A, B = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B divs = divisors(A) divs divisors(A) divisors A i = 1 i 1 cnt = 0 cnt 0 while i < len(divs):
        if B%divs[i]==0 and is_prime(divs[i]):
            cnt += 1
        i += 1
     i < len(divs) i len(divs) len divs if B%divs[i]==0 and is_prime(divs[i]):
            cnt += 1
         B%divs[i]==0 and is_prime(divs[i]) B%divs[i]==0 B%divs[i] B divs[i] divs i 0 is_prime(divs[i]) is_prime divs[i] divs i cnt += 1 cnt 1 i += 1 i 1 print(cnt+1) print cnt+1 cnt 1 if '__main__' == __name__:
    resolve() '__main__' == __name__ '__main__' __name__ resolve() resolve def is_prime(n):
    if n == 2 or n == 3: return True
    if n < 2 or n%2 == 0: return False
    if n < 9: return True
    if n%3 == 0: return False
    r = int(n**0.5)
    f = 5
    while f <= r:
        if n%f == 0: return False
        if n%(f+2) == 0: return False
        f +=6
    return True   def is_prime(n):
    if n == 2 or n == 3: return True
    if n < 2 or n%2 == 0: return False
    if n < 9: return True
    if n%3 == 0: return False
    r = int(n**0.5)
    f = 5
    while f <= r:
        if n%f == 0: return False
        if n%(f+2) == 0: return False
        f +=6
    return True   is_prime def resolve():
    A, B = list(map(int, input().split()))
    divs = divisors(A)
    i = 1
    cnt = 0
    while i < len(divs):
        if B%divs[i]==0 and is_prime(divs[i]):
            cnt += 1
        i += 1
    print(cnt+1)
     def resolve():
    A, B = list(map(int, input().split()))
    divs = divisors(A)
    i = 1
    cnt = 0
    while i < len(divs):
        if B%divs[i]==0 and is_prime(divs[i]):
            cnt += 1
        i += 1
    print(cnt+1)
     resolve def divisors(n):
    lower_divs , upper_divs = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs + upper_divs[::-1] def divisors(n):
    lower_divs , upper_divs = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs + upper_divs[::-1] divisors
def is_prime(n):
    if n == 2 or n == 3: return True
    if n < 2 or n%2 == 0: return False
    if n < 9: return True
    if n%3 == 0: return False
    r = int(n**0.5)
    f = 5
    while f <= r:
        if n%f == 0: return False
        if n%(f+2) == 0: return False
        f +=6
    return True  

def divisors(n):
    lower_divs , upper_divs = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs + upper_divs[::-1]

def resolve():
    A, B = list(map(int, input().split()))
    divs = divisors(A)
    i = 1
    cnt = 0
    while i < len(divs):
        if B%divs[i]==0 and is_prime(divs[i]):
            cnt += 1
        i += 1
    print(cnt+1)
    

if '__main__' == __name__:
    resolve()
