import math

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1

a,b=map(int,input().split())
c=math.gcd(a,b)

if isPrime(c)==1:
    print(2)
else:
    icnt=0
    for i in enum_div(c):
        if isPrime(i)==1:
            icnt+=1
    print(icnt+1) import math math def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret enum_div ir=int(n**(0.5))+1 ir int(n**(0.5))+1 int(n**(0.5)) int n**(0.5) n 0.5 1 ret=[] ret [] for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
     i range(1,ir) range 1 ir if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
     n%i == 0 n%i n i 0 ret.append(i) ret.append ret append i if (i!= 1) & (i*i != n):
                ret.append(n//i)
     (i!= 1) & (i*i != n) i!= 1 i 1 i*i != n i*i i i n ret.append(n//i) ret.append ret append n//i n i return ret ret n n def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1 isPrime if x < 2:
        return 0
    elif x == 2:
        return 1
     x < 2 x 2 return 0 0 elif x == 2:
        return 1
     x == 2 x 2 return 1 1 if x%2 == 0:
        return 0
     x%2 == 0 x%2 x 2 0 return 0 0 ir=int(x**(0.5))+1 ir int(x**(0.5))+1 int(x**(0.5)) int x**(0.5) x 0.5 1 for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
     i range(3,ir,2) range 3 ir 2 if x%i == 0:
            return 0
     x%i == 0 x%i x i 0 return 0 0 return 1 1 x x a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c=math.gcd(a,b) c math.gcd(a,b) math.gcd math gcd a b if isPrime(c)==1:
    print(2)
else:
    icnt=0
    for i in enum_div(c):
        if isPrime(i)==1:
            icnt+=1
    print(icnt+1) isPrime(c)==1 isPrime(c) isPrime c 1 print(2) print 2 icnt=0 icnt 0 for i in enum_div(c):
        if isPrime(i)==1:
            icnt+=1
     i enum_div(c) enum_div c if isPrime(i)==1:
            icnt+=1
     isPrime(i)==1 isPrime(i) isPrime i 1 icnt+=1 icnt 1 print(icnt+1) print icnt+1 icnt 1 a,b=map(int,input().split()) map(int,input().split()) a c=math.gcd(a,b) math.gcd(a,b) c def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret enum_div icnt+=1 1 icnt def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1 def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1 isPrime b=map(int,input().split()) map(int,input().split()) b icnt=0 0 icnt
import math

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1

a,b=map(int,input().split())
c=math.gcd(a,b)

if isPrime(c)==1:
    print(2)
else:
    icnt=0
    for i in enum_div(c):
        if isPrime(i)==1:
            icnt+=1
    print(icnt+1)