def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#============================
from math import gcd
A,B=map(int,input().split())
G=gcd(A,B)

if G==1:
    print(1)
else:
    P=Prime_Factorization(G)
    print(len(P)+1) def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#============================ Prime_Factorization if N<0:
        R=[[-1,1]]
    else:
        R=[]

     N<0 N 0 R=[[-1,1]] R [[-1,1]] [-1,1] -1 1 R=[] R [] N=abs(N) N abs(N) abs N k=2 k 2 while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

     k*k<=N k*k k k N if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
         N%k==0 N%k N k 0 C=0 C 0 while N%k==0:
                C+=1
                N//=k
             N%k==0 N%k N k 0 C+=1 C 1 N//=k N k R.append([k,C]) R.append R append [k,C] k C k+=1 k 1 if N!=1:
        R.append([N,1])
     N!=1 N 1 R.append([N,1]) R.append R append [N,1] N 1 if not R:
        R.append([N,1])

     not R R R.append([N,1]) R.append R append [N,1] N 1 return R R N N from math import gcd A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B G=gcd(A,B) G gcd(A,B) gcd A B if G==1:
    print(1)
else:
    P=Prime_Factorization(G)
    print(len(P)+1) G==1 G 1 print(1) print 1 P=Prime_Factorization(G) P Prime_Factorization(G) Prime_Factorization G print(len(P)+1) print len(P)+1 len(P) len P 1 B=map(int,input().split()) map(int,input().split()) B def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#============================ def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#============================ Prime_Factorization A,B=map(int,input().split()) map(int,input().split()) A G=gcd(A,B) gcd(A,B) G P=Prime_Factorization(G) Prime_Factorization(G) P
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R
#============================
from math import gcd
A,B=map(int,input().split())
G=gcd(A,B)

if G==1:
    print(1)
else:
    P=Prime_Factorization(G)
    print(len(P)+1)