import math
A,B = map(int,input().split())
C = math.gcd(A,B)

#N以下の素数れっきょエラトステネス
def prime(N):
    lsprime = [0,0]+[1 for i in range(N-1)]
    lsprime2 = []
    for i in range(N+1):
        if lsprime[i] == 0:
            continue
        lsprime2.append(i)
        k = i
        while i <= N:
            lsprime[i] = 0
            i += k
    return lsprime2

#素因数分解
def prime2(N):
    arr = []
    temp = N
    setprime = set()
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            setprime.add(i)
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
        setprime.add(temp)

    if arr==[]:
        arr.append([N, 1])

    return arr,setprime

_,setp = prime2(C)
print(len(setp)+1) import math math 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 def prime(N):
    lsprime = [0,0]+[1 for i in range(N-1)]
    lsprime2 = []
    for i in range(N+1):
        if lsprime[i] == 0:
            continue
        lsprime2.append(i)
        k = i
        while i <= N:
            lsprime[i] = 0
            i += k
    return lsprime2

#素因数分解 prime 1 for i in range(N-1) for i in range(N-1) i range(N-1) range N-1 N 1 for i in range(N-1) 1 lsprime = [0,0]+[1 for i in range(N-1)] lsprime [0,0]+[1 for i in range(N-1)] [0,0] 0 0 [1 for i in range(N-1)] lsprime2 = [] lsprime2 [] for i in range(N+1):
        if lsprime[i] == 0:
            continue
        lsprime2.append(i)
        k = i
        while i <= N:
            lsprime[i] = 0
            i += k
     i range(N+1) range N+1 N 1 if lsprime[i] == 0:
            continue
         lsprime[i] == 0 lsprime[i] lsprime i 0 continue lsprime2.append(i) lsprime2.append lsprime2 append i k = i k i while i <= N:
            lsprime[i] = 0
            i += k
     i <= N i N lsprime[i] = 0 lsprime[i] lsprime i 0 i += k i k return lsprime2 lsprime2 N N def prime2(N):
    arr = []
    temp = N
    setprime = set()
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            setprime.add(i)
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
        setprime.add(temp)

    if arr==[]:
        arr.append([N, 1])

    return arr,setprime prime2 arr = [] arr [] temp = N temp N setprime = set() setprime set() set for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            setprime.add(i)
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
     i range(2, int(-(-N**0.5//1))+1) range 2 int(-(-N**0.5//1))+1 int(-(-N**0.5//1)) int -(-N**0.5//1) -N**0.5//1 -N**0.5 N**0.5 N 0.5 1 1 if temp%i==0:
            cnt=0
            setprime.add(i)
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
     temp%i==0 temp%i temp i 0 cnt=0 cnt 0 setprime.add(i) setprime.add setprime add i while temp%i==0:
                cnt+=1
                temp //= i
             temp%i==0 temp%i temp i 0 cnt+=1 cnt 1 temp //= i temp i arr.append([i, cnt]) arr.append arr append [i, cnt] i cnt if temp!=1:
        arr.append([temp, 1])
        setprime.add(temp)

     temp!=1 temp 1 arr.append([temp, 1]) arr.append arr append [temp, 1] temp 1 setprime.add(temp) setprime.add setprime add temp if arr==[]:
        arr.append([N, 1])

     arr==[] arr [] arr.append([N, 1]) arr.append arr append [N, 1] N 1 return arr,setprime return arr,setprime arr setprime N N _,setp = prime2(C) _ prime2(C) prime2 C setp print(len(setp)+1) print len(setp)+1 len(setp) len setp 1 A,B = map(int,input().split()) map(int,input().split()) A B = map(int,input().split()) map(int,input().split()) B def prime(N):
    lsprime = [0,0]+[1 for i in range(N-1)]
    lsprime2 = []
    for i in range(N+1):
        if lsprime[i] == 0:
            continue
        lsprime2.append(i)
        k = i
        while i <= N:
            lsprime[i] = 0
            i += k
    return lsprime2

#素因数分解 def prime(N):
    lsprime = [0,0]+[1 for i in range(N-1)]
    lsprime2 = []
    for i in range(N+1):
        if lsprime[i] == 0:
            continue
        lsprime2.append(i)
        k = i
        while i <= N:
            lsprime[i] = 0
            i += k
    return lsprime2

#素因数分解 prime _,setp = prime2(C) prime2(C) _ C = math.gcd(A,B) math.gcd(A,B) C def prime2(N):
    arr = []
    temp = N
    setprime = set()
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            setprime.add(i)
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
        setprime.add(temp)

    if arr==[]:
        arr.append([N, 1])

    return arr,setprime def prime2(N):
    arr = []
    temp = N
    setprime = set()
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            setprime.add(i)
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
        setprime.add(temp)

    if arr==[]:
        arr.append([N, 1])

    return arr,setprime prime2 setp = prime2(C) prime2(C) setp
import math
A,B = map(int,input().split())
C = math.gcd(A,B)

#N以下の素数れっきょエラトステネス
def prime(N):
    lsprime = [0,0]+[1 for i in range(N-1)]
    lsprime2 = []
    for i in range(N+1):
        if lsprime[i] == 0:
            continue
        lsprime2.append(i)
        k = i
        while i <= N:
            lsprime[i] = 0
            i += k
    return lsprime2

#素因数分解
def prime2(N):
    arr = []
    temp = N
    setprime = set()
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            setprime.add(i)
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
        setprime.add(temp)

    if arr==[]:
        arr.append([N, 1])

    return arr,setprime

_,setp = prime2(C)
print(len(setp)+1)