import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr
A,B = map(int,input().split())
Af = factorization(A)
Bf = factorization(B)
As = set()
Bs = set()
for i in range(len(Af)):
    As.add(Af[i][0])
for j in range(len(Bf)):
    Bs.add(Bf[j][0])
if A == 1 and B ==1:
    print(1)
else:
    print(len(As & Bs)+1) import math math def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr factorization arr = [] arr [] temp = n temp n for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            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
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

     temp%i==0 temp%i temp i 0 cnt=0 cnt 0 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])

     temp!=1 temp 1 arr.append([temp, 1]) arr.append arr append [temp, 1] temp 1 if arr==[]:
        arr.append([n, 1])

     arr==[] arr [] arr.append([n, 1]) arr.append arr append [n, 1] n 1 return arr arr n n A,B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B Af = factorization(A) Af factorization(A) factorization A Bf = factorization(B) Bf factorization(B) factorization B As = set() As set() set Bs = set() Bs set() set for i in range(len(Af)):
    As.add(Af[i][0]) i range(len(Af)) range len(Af) len Af As.add(Af[i][0]) As.add As add Af[i][0] [i] Af i 0 for j in range(len(Bf)):
    Bs.add(Bf[j][0]) j range(len(Bf)) range len(Bf) len Bf Bs.add(Bf[j][0]) Bs.add Bs add Bf[j][0] [j] Bf j 0 if A == 1 and B ==1:
    print(1)
else:
    print(len(As & Bs)+1) A == 1 and B ==1 A == 1 A 1 B ==1 B 1 print(1) print 1 print(len(As & Bs)+1) print len(As & Bs)+1 len(As & Bs) len As & Bs As Bs 1 A,B = map(int,input().split()) map(int,input().split()) A Bs = set() set() Bs Bf = factorization(B) factorization(B) Bf Af = factorization(A) factorization(A) Af As = set() set() As B = map(int,input().split()) map(int,input().split()) B def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr factorization
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr
A,B = map(int,input().split())
Af = factorization(A)
Bf = factorization(B)
As = set()
Bs = set()
for i in range(len(Af)):
    As.add(Af[i][0])
for j in range(len(Bf)):
    Bs.add(Bf[j][0])
if A == 1 and B ==1:
    print(1)
else:
    print(len(As & Bs)+1)