import collections as col



def prime(n):

    ans = []

    num = n

    for i in range(2,int(n**0.5)+1):

        if i%2==0 and i!=2: continue

        while num%i == 0: num //= i ; ans.append(i)

    if num != 1: ans.append(num)

    return ans



def gcd(a,b): return gcd(b,a%b) if a%b else b



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

primes = prime(gcd(a,b))

cnt = col.Counter(primes)

ans = len(cnt) + 1

print(ans)

        

import collections as col

import math



def prime(n):

    ans = []

    num = n

    for i in range(2,int(n**0.5)+1):

        if i%2==0 and i!=2: continue

        while num%i == 0: num //= i ; ans.append(i)

    if num != 1: ans.append(num)

    return ans



def gcd(a,b): return gcd(b,a%b) if a%b else b



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

primes = prime(gcd(a,b)) #math.gcdは使用禁止？

cnt = col.Counter(primes)

ans = len(cnt) + 1

print(ans)

        

import collections as col


def prime(n):
    ans = []
    num = n
    for i in range(2, int(n**0.5) + 1):
        if i % 2 == 0 and i != 2:
            continue
        while num % i == 0:
            num //= i
            ans.append(i)
    if num != 1:
        ans.append(num)
    return ans


def gcd(a, b):
    return gcd(b, a % b) if a % b else b


a, b = list(map(int, input().split()))
primes = prime(gcd(a, b))
cnt = col.Counter(primes)
ans = len(cnt) + 1
print(ans)

import collections as col
import math


def prime(n):
    ans = []
    num = n
    for i in range(2, int(n**0.5) + 1):
        if i % 2 == 0 and i != 2:
            continue
        while num % i == 0:
            num //= i
            ans.append(i)
    if num != 1:
        ans.append(num)
    return ans


def gcd(a, b):
    return gcd(b, a % b) if a % b else b


a, b = list(map(int, input().split()))
primes = prime(gcd(a, b))  # math.gcdは使用禁止？
cnt = col.Counter(primes)
ans = len(cnt) + 1
print(ans)

+import math -primes = prime(gcd(a, b)) +primes = prime(gcd(a, b))  # math.gcdは使用禁止？