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[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr=={}:
        arr[n] = 1

    return arr


a, b = map(int, input().split()) 
a_fac = factorization(a)
b_fac = factorization(b)
lcm = {}
for prime,cnt in a_fac.items():
    if prime in b_fac and prime != 1:
        lcm[prime] = min(cnt, b_fac[prime])

print(len(lcm)+1) 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[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr=={}:
        arr[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[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[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[i] = cnt arr[i] arr i cnt if temp!=1:
        arr[temp] = 1

     temp!=1 temp 1 arr[temp] = 1 arr[temp] arr temp 1 if arr=={}:
        arr[n] = 1

     arr=={} arr {} arr[n] = 1 arr[n] arr 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 a_fac = factorization(a) a_fac factorization(a) factorization a b_fac = factorization(b) b_fac factorization(b) factorization b lcm = {} lcm {} for prime,cnt in a_fac.items():
    if prime in b_fac and prime != 1:
        lcm[prime] = min(cnt, b_fac[prime]) prime cnt a_fac.items() a_fac.items a_fac items if prime in b_fac and prime != 1:
        lcm[prime] = min(cnt, b_fac[prime]) prime in b_fac and prime != 1 prime in b_fac prime b_fac prime != 1 prime 1 lcm[prime] = min(cnt, b_fac[prime]) lcm[prime] lcm prime min(cnt, b_fac[prime]) min cnt b_fac[prime] b_fac prime print(len(lcm)+1) print len(lcm)+1 len(lcm) len lcm 1 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[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr=={}:
        arr[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[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr=={}:
        arr[n] = 1

    return arr factorization a_fac = factorization(a) factorization(a) a_fac b = map(int, input().split()) map(int, input().split()) b lcm = {} {} lcm a, b = map(int, input().split()) map(int, input().split()) a b_fac = factorization(b) factorization(b) b_fac
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[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr=={}:
        arr[n] = 1

    return arr


a, b = map(int, input().split()) 
a_fac = factorization(a)
b_fac = factorization(b)
lcm = {}
for prime,cnt in a_fac.items():
    if prime in b_fac and prime != 1:
        lcm[prime] = min(cnt, b_fac[prime])

print(len(lcm)+1)