from math import gcd
import random
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1


def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

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())
l = make_divisors(gcd(A, B))
_l = factorization(gcd(A, B))
ans = 0
#print(gcd(A, B))
#print(l)
#print(_l)
for num in l:
    if is_prime3(num):
        #print(num)
        ans += 1
print(ans + 1)
 from math import gcd import random random def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors lower_divisors , upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
     i*i <= n i*i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n//i)
         i != n // i i n // i n i upper_divisors.append(n//i) upper_divisors.append upper_divisors append n//i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1 is_prime q = abs(q) q abs(q) abs q if q == 2: return True
     q == 2 q 2 if q < 2 or q&1 == 0: return False
     q < 2 or q&1 == 0 q < 2 q 2 q&1 == 0 q&1 q 1 0 return pow(2, q-1, q) == 1 pow(2, q-1, q) == 1 pow(2, q-1, q) pow 2 q-1 q 1 q 1 q q def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True is_prime3 q = abs(q) q abs(q) abs q if q == 2: return True
     q == 2 q 2 if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
     q < 2 or q & 1 == 0 q < 2 q 2 q & 1 == 0 q & 1 q 1 0 d = (q - 1) >> 1 d (q - 1) >> 1 q - 1 q 1 1 while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
     d & 1 == 0 d & 1 d 1 0 d >>= 1 d 1 for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
     i range(k) range k a = random.randint(1, q - 1) a random.randint(1, q - 1) random.randint random randint 1 q - 1 q 1 t = d t d y = pow(a, t, q) y pow(a, t, q) pow a t q while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
         t != q - 1 and y != 1 and y != q - 1 t != q - 1 and y != 1 t != q - 1 t q - 1 q 1 y != 1 y 1 y != q - 1 y q - 1 q 1 y = pow(y, 2, q) y pow(y, 2, q) pow y 2 q t <<= 1 t 1 if y != q - 1 and t & 1 == 0:
            return False
     y != q - 1 and t & 1 == 0 y != q - 1 y q - 1 q 1 t & 1 == 0 t & 1 t 1 0 return False False return True True q q k=50 k 50 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 l = make_divisors(gcd(A, B)) l make_divisors(gcd(A, B)) make_divisors gcd(A, B) gcd A B _l = factorization(gcd(A, B)) _l factorization(gcd(A, B)) factorization gcd(A, B) gcd A B ans = 0 ans 0 for num in l:
    if is_prime3(num):
        #print(num)
        ans += 1 num l if is_prime3(num):
        #print(num)
        ans += 1 is_prime3(num) is_prime3 num ans += 1 ans 1 print(ans + 1) print ans + 1 ans 1 def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1 def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1 is_prime B = map(int, input().split()) map(int, input().split()) B ans += 1 1 ans def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors l = make_divisors(gcd(A, B)) make_divisors(gcd(A, B)) l ans = 0 0 ans 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 A, B = map(int, input().split()) map(int, input().split()) A _l = factorization(gcd(A, B)) factorization(gcd(A, B)) _l def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True is_prime3
from math import gcd
import random
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1


def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

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())
l = make_divisors(gcd(A, B))
_l = factorization(gcd(A, B))
ans = 0
#print(gcd(A, B))
#print(l)
#print(_l)
for num in l:
    if is_prime3(num):
        #print(num)
        ans += 1
print(ans + 1)

