### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import collections

def yn(b):
    print("Yes" if b==1 else "No")
    return

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 resolve():
    readline=sys.stdin.readline
    a,b=map(int, readline().rstrip().split())

    af = factorization(a)
    bf = factorization(b)

    c = collections.Counter()
    c[1]=2
    for x in af:
        c[x[0]]+=1
    for x in bf:
        c[x[0]]+=1
    ans=0
    for k in c.keys():
        if c[k]>=2:
            ans+=1
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ---------------- import sys sys from io import StringIO import unittest unittest import collections collections def yn(b):
    print("Yes" if b==1 else "No")
    return yn print("Yes" if b==1 else "No") print "Yes" if b==1 else "No" b==1 b 1 "Yes" "No" return b 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 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 def resolve():
    readline=sys.stdin.readline
    a,b=map(int, readline().rstrip().split())

    af = factorization(a)
    bf = factorization(b)

    c = collections.Counter()
    c[1]=2
    for x in af:
        c[x[0]]+=1
    for x in bf:
        c[x[0]]+=1
    ans=0
    for k in c.keys():
        if c[k]>=2:
            ans+=1
    print(ans)

    return resolve readline=sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline a,b=map(int, readline().rstrip().split()) a map(int, readline().rstrip().split()) map int readline().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () readline rstrip split b af = factorization(a) af factorization(a) factorization a bf = factorization(b) bf factorization(b) factorization b c = collections.Counter() c collections.Counter() collections.Counter collections Counter c[1]=2 c[1] c 1 2 for x in af:
        c[x[0]]+=1
     x af c[x[0]]+=1 c[x[0]] c x[0] x 0 1 for x in bf:
        c[x[0]]+=1
     x bf c[x[0]]+=1 c[x[0]] c x[0] x 0 1 ans=0 ans 0 for k in c.keys():
        if c[k]>=2:
            ans+=1
     k c.keys() c.keys c keys if c[k]>=2:
            ans+=1
     c[k]>=2 c[k] c k 2 ans+=1 ans 1 print(ans) print ans return if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ---------------- 'doTest' not in globals() 'doTest' globals() globals resolve() resolve sys.exit() sys.exit sys exit def yn(b):
    print("Yes" if b==1 else "No")
    return def yn(b):
    print("Yes" if b==1 else "No")
    return yn 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 def resolve():
    readline=sys.stdin.readline
    a,b=map(int, readline().rstrip().split())

    af = factorization(a)
    bf = factorization(b)

    c = collections.Counter()
    c[1]=2
    for x in af:
        c[x[0]]+=1
    for x in bf:
        c[x[0]]+=1
    ans=0
    for k in c.keys():
        if c[k]>=2:
            ans+=1
    print(ans)

    return def resolve():
    readline=sys.stdin.readline
    a,b=map(int, readline().rstrip().split())

    af = factorization(a)
    bf = factorization(b)

    c = collections.Counter()
    c[1]=2
    for x in af:
        c[x[0]]+=1
    for x in bf:
        c[x[0]]+=1
    ans=0
    for k in c.keys():
        if c[k]>=2:
            ans+=1
    print(ans)

    return resolve
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import collections

def yn(b):
    print("Yes" if b==1 else "No")
    return

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 resolve():
    readline=sys.stdin.readline
    a,b=map(int, readline().rstrip().split())

    af = factorization(a)
    bf = factorization(b)

    c = collections.Counter()
    c[1]=2
    for x in af:
        c[x[0]]+=1
    for x in bf:
        c[x[0]]+=1
    ans=0
    for k in c.keys():
        if c[k]>=2:
            ans+=1
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------