# Coding is about expressing your feeling, and
# there is always a better way to express your feeling_feelme
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=int(1e9 + 7)

def divisor(n):
    ans={}
    m=int(n**0.5)+1
    for i in range(1,m):
        if n%i==0:
            ans[i]=1
            ans[n//i]=1
    return ans
def prime(n):
    if n<=3:
        return True
    m=int(n**0.5)+1
    if n%2==0:
        return False
    for i in range(3,m,2):
        if n%i==0:
            return False
    return True

a,b=iia()
ans=divisor(a)
ans2=divisor(b)
res=[]
for i,j in ans.items():
    if i in ans2:
        res.append(i)

#print(res)
count=0
for i in res:
    if prime(i):
        count+=1
print(count)
 import sys sys import math math from sys import stdin,stdout from collections import deque,defaultdict from math import ceil,floor,inf,sqrt,factorial,gcd,log2 from copy import deepcopy ii1=lambda:int(stdin.readline().strip()) ii1 lambda:int(stdin.readline().strip()) int(stdin.readline().strip()) int stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip is1=lambda:stdin.readline().strip() is1 lambda:stdin.readline().strip() stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip iia=lambda:list(map(int,stdin.readline().strip().split())) iia lambda:list(map(int,stdin.readline().strip().split())) list(map(int,stdin.readline().strip().split())) list map(int,stdin.readline().strip().split()) map int stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split isa=lambda:stdin.readline().strip().split() isa lambda:stdin.readline().strip().split() stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split mod=int(1e9 + 7) mod int(1e9 + 7) int 1e9 + 7 1e9 7 def divisor(n):
    ans={}
    m=int(n**0.5)+1
    for i in range(1,m):
        if n%i==0:
            ans[i]=1
            ans[n//i]=1
    return ans divisor ans={} ans {} m=int(n**0.5)+1 m int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 for i in range(1,m):
        if n%i==0:
            ans[i]=1
            ans[n//i]=1
     i range(1,m) range 1 m if n%i==0:
            ans[i]=1
            ans[n//i]=1
     n%i==0 n%i n i 0 ans[i]=1 ans[i] ans i 1 ans[n//i]=1 ans[n//i] ans n//i n i 1 return ans ans n n def prime(n):
    if n<=3:
        return True
    m=int(n**0.5)+1
    if n%2==0:
        return False
    for i in range(3,m,2):
        if n%i==0:
            return False
    return True prime if n<=3:
        return True
     n<=3 n 3 return True True m=int(n**0.5)+1 m int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n%2==0:
        return False
     n%2==0 n%2 n 2 0 return False False for i in range(3,m,2):
        if n%i==0:
            return False
     i range(3,m,2) range 3 m 2 if n%i==0:
            return False
     n%i==0 n%i n i 0 return False False return True True n n a,b=iia() a iia() iia b ans=divisor(a) ans divisor(a) divisor a ans2=divisor(b) ans2 divisor(b) divisor b res=[] res [] for i,j in ans.items():
    if i in ans2:
        res.append(i)

#print(res) i j ans.items() ans.items ans items if i in ans2:
        res.append(i)

#print(res) i in ans2 i ans2 res.append(i) res.append res append i count=0 count 0 for i in res:
    if prime(i):
        count+=1 i res if prime(i):
        count+=1 prime(i) prime i count+=1 count 1 print(count) print count isa=lambda:stdin.readline().strip().split() lambda:stdin.readline().strip().split() isa b=iia() iia() b mod=int(1e9 + 7) int(1e9 + 7) mod def prime(n):
    if n<=3:
        return True
    m=int(n**0.5)+1
    if n%2==0:
        return False
    for i in range(3,m,2):
        if n%i==0:
            return False
    return True def prime(n):
    if n<=3:
        return True
    m=int(n**0.5)+1
    if n%2==0:
        return False
    for i in range(3,m,2):
        if n%i==0:
            return False
    return True prime count=0 0 count ans=divisor(a) divisor(a) ans count+=1 1 count iia=lambda:list(map(int,stdin.readline().strip().split())) lambda:list(map(int,stdin.readline().strip().split())) iia a,b=iia() iia() a ii1=lambda:int(stdin.readline().strip()) lambda:int(stdin.readline().strip()) ii1 def divisor(n):
    ans={}
    m=int(n**0.5)+1
    for i in range(1,m):
        if n%i==0:
            ans[i]=1
            ans[n//i]=1
    return ans def divisor(n):
    ans={}
    m=int(n**0.5)+1
    for i in range(1,m):
        if n%i==0:
            ans[i]=1
            ans[n//i]=1
    return ans divisor is1=lambda:stdin.readline().strip() lambda:stdin.readline().strip() is1 ans2=divisor(b) divisor(b) ans2 res=[] [] res
# Coding is about expressing your feeling, and
# there is always a better way to express your feeling_feelme
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=int(1e9 + 7)

def divisor(n):
    ans={}
    m=int(n**0.5)+1
    for i in range(1,m):
        if n%i==0:
            ans[i]=1
            ans[n//i]=1
    return ans
def prime(n):
    if n<=3:
        return True
    m=int(n**0.5)+1
    if n%2==0:
        return False
    for i in range(3,m,2):
        if n%i==0:
            return False
    return True

a,b=iia()
ans=divisor(a)
ans2=divisor(b)
res=[]
for i,j in ans.items():
    if i in ans2:
        res.append(i)

#print(res)
count=0
for i in res:
    if prime(i):
        count+=1
print(count)

