a, b = list(map(int, input().split()))



import math



def prime(n):

  if n == 1:

    return False

  i = 1

  while i < int(math.sqrt(n)):

    i += 1

    if n%i == 0:

      return False

  else:

    return True



#print(prime(1))



if prime(a) and prime(b) and a==b:

  print((2))

  exit()

  

if a-b == 1 or b-a == 1:

  print((1))

  exit()



l = []

for i in range(1, max(int(math.sqrt(a))+2, int(math.sqrt(b))+2)):

  if i == 1:

    l.append(i)

  else:

    if a%i == 0 and b%i == 0 and prime(i):

      l.append(i)

    j = a//i

    if j != 0:

      if b%j == 0 and prime(j):

        l.append(j)

    k = b//i

    if k != 0:

      if a%k == 0 and prime(k):

        l.append(k)

#print(set(l))

print((len(set(l))))

               
a, b = list(map(int, input().split()))



import fractions

g = fractions.gcd(a, b)



import math



def div(m):

    d = {}

    temp = int(math.sqrt(m))+1

    for i in range(2, temp):

        while m%i== 0:

            m //= i

            if i in d:

                d[i] += 1

            else:

                d[i] = 1

    if d == {}:

        d[m] = 1

    else:

        if m in d:

            d[m] += 1

        elif m != 1:

            d[m] =1

    return d



d = div(g)

#print(d)

if 1 not in d:

    ans = len(d)+1

else:

    ans = 1

print(ans)

a, b = list(map(int, input().split()))
import math


def prime(n):
    if n == 1:
        return False
    i = 1
    while i < int(math.sqrt(n)):
        i += 1
        if n % i == 0:
            return False
    else:
        return True


# print(prime(1))
if prime(a) and prime(b) and a == b:
    print((2))
    exit()
if a - b == 1 or b - a == 1:
    print((1))
    exit()
l = []
for i in range(1, max(int(math.sqrt(a)) + 2, int(math.sqrt(b)) + 2)):
    if i == 1:
        l.append(i)
    else:
        if a % i == 0 and b % i == 0 and prime(i):
            l.append(i)
        j = a // i
        if j != 0:
            if b % j == 0 and prime(j):
                l.append(j)
        k = b // i
        if k != 0:
            if a % k == 0 and prime(k):
                l.append(k)
# print(set(l))
print((len(set(l))))

a, b = list(map(int, input().split()))
import fractions

g = fractions.gcd(a, b)
import math


def div(m):
    d = {}
    temp = int(math.sqrt(m)) + 1
    for i in range(2, temp):
        while m % i == 0:
            m //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[m] = 1
    else:
        if m in d:
            d[m] += 1
        elif m != 1:
            d[m] = 1
    return d


d = div(g)
# print(d)
if 1 not in d:
    ans = len(d) + 1
else:
    ans = 1
print(ans)

+import fractions + +g = fractions.gcd(a, b) -def prime(n): -    if n == 1: -        return False -    i = 1 -    while i < int(math.sqrt(n)): -        i += 1 -        if n % i == 0: -            return False +def div(m): +    d = {} +    temp = int(math.sqrt(m)) + 1 +    for i in range(2, temp): +        while m % i == 0: +            m //= i +            if i in d: +                d[i] += 1 +            else: +                d[i] = 1 +    if d == {}: +        d[m] = 1 -        return True +        if m in d: +            d[m] += 1 +        elif m != 1: +            d[m] = 1 +    return d -# print(prime(1)) -if prime(a) and prime(b) and a == b: -    print((2)) -    exit() -if a - b == 1 or b - a == 1: -    print((1)) -    exit() -l = [] -for i in range(1, max(int(math.sqrt(a)) + 2, int(math.sqrt(b)) + 2)): -    if i == 1: -        l.append(i) -    else: -        if a % i == 0 and b % i == 0 and prime(i): -            l.append(i) -        j = a // i -        if j != 0: -            if b % j == 0 and prime(j): -                l.append(j) -        k = b // i -        if k != 0: -            if a % k == 0 and prime(k): -                l.append(k) -# print(set(l)) -print((len(set(l)))) +d = div(g) +# print(d) +if 1 not in d: +    ans = len(d) + 1 +else: +    ans = 1 +print(ans)