import math

def isprime(n):
    if(n == 1):
        return True
    if(n == 2):
        return True
    if(n%2 == 0):
        return False
    for i in range(3, int(math.sqrt(n))+1, 2):
        if(n%i == 0):
            return False
        
    return True

def yakusuu(n):
    l = []
    u = []
    i = 1
    while(i*i <= n):
        if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
        i += 1
    return l+u[::-1]
        
A, B = map(int, input().split())
a = set(yakusuu(A))
b = set(yakusuu(B))

lst = []
for i in a:
    if(i in b):
        lst.append(i)
   
cnt = 0
for i in range(len(lst)):
    if(isprime(lst[i])):
        cnt += 1
    
print(cnt) import math math def isprime(n):
    if(n == 1):
        return True
    if(n == 2):
        return True
    if(n%2 == 0):
        return False
    for i in range(3, int(math.sqrt(n))+1, 2):
        if(n%i == 0):
            return False
        
    return True isprime if(n == 1):
        return True
     n == 1 n 1 return True True if(n == 2):
        return True
     n == 2 n 2 return True True if(n%2 == 0):
        return False
     n%2 == 0 n%2 n 2 0 return False False for i in range(3, int(math.sqrt(n))+1, 2):
        if(n%i == 0):
            return False
        
     i range(3, int(math.sqrt(n))+1, 2) range 3 int(math.sqrt(n))+1 int(math.sqrt(n)) int math.sqrt(n) math.sqrt math sqrt n 1 2 if(n%i == 0):
            return False
        
     n%i == 0 n%i n i 0 return False False return True True n n def yakusuu(n):
    l = []
    u = []
    i = 1
    while(i*i <= n):
        if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
        i += 1
    return l+u[::-1]
         yakusuu l = [] l [] u = [] u [] i = 1 i 1 while(i*i <= n):
        if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
        i += 1
     i*i <= n i*i i i n if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
         n%i == 0 n%i n i 0 l.append(i) l.append l append i if(i != n//i):
                u.append(n//i)
         i != n//i i n//i n i u.append(n//i) u.append u append n//i n i i += 1 i 1 return l+u[::-1] l+u[::-1] l u[::-1] u ::-1 -1 n n A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B a = set(yakusuu(A)) a set(yakusuu(A)) set yakusuu(A) yakusuu A b = set(yakusuu(B)) b set(yakusuu(B)) set yakusuu(B) yakusuu B lst = [] lst [] for i in a:
    if(i in b):
        lst.append(i)
    i a if(i in b):
        lst.append(i)
    i in b i b lst.append(i) lst.append lst append i cnt = 0 cnt 0 for i in range(len(lst)):
    if(isprime(lst[i])):
        cnt += 1
     i range(len(lst)) range len(lst) len lst if(isprime(lst[i])):
        cnt += 1
     isprime(lst[i]) isprime lst[i] lst i cnt += 1 cnt 1 print(cnt) print cnt a = set(yakusuu(A)) set(yakusuu(A)) a def yakusuu(n):
    l = []
    u = []
    i = 1
    while(i*i <= n):
        if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
        i += 1
    return l+u[::-1]
         def yakusuu(n):
    l = []
    u = []
    i = 1
    while(i*i <= n):
        if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
        i += 1
    return l+u[::-1]
         yakusuu cnt += 1 1 cnt cnt = 0 0 cnt B = map(int, input().split()) map(int, input().split()) B b = set(yakusuu(B)) set(yakusuu(B)) b A, B = map(int, input().split()) map(int, input().split()) A def isprime(n):
    if(n == 1):
        return True
    if(n == 2):
        return True
    if(n%2 == 0):
        return False
    for i in range(3, int(math.sqrt(n))+1, 2):
        if(n%i == 0):
            return False
        
    return True def isprime(n):
    if(n == 1):
        return True
    if(n == 2):
        return True
    if(n%2 == 0):
        return False
    for i in range(3, int(math.sqrt(n))+1, 2):
        if(n%i == 0):
            return False
        
    return True isprime lst = [] [] lst
import math

def isprime(n):
    if(n == 1):
        return True
    if(n == 2):
        return True
    if(n%2 == 0):
        return False
    for i in range(3, int(math.sqrt(n))+1, 2):
        if(n%i == 0):
            return False
        
    return True

def yakusuu(n):
    l = []
    u = []
    i = 1
    while(i*i <= n):
        if(n%i == 0):
            l.append(i)
            if(i != n//i):
                u.append(n//i)
        i += 1
    return l+u[::-1]
        
A, B = map(int, input().split())
a = set(yakusuu(A))
b = set(yakusuu(B))

lst = []
for i in a:
    if(i in b):
        lst.append(i)
   
cnt = 0
for i in range(len(lst)):
    if(isprime(lst[i])):
        cnt += 1
    
print(cnt)