import numpy as np

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]
A, B = map(int, input().split())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

#_, primes = make_prime(10**8)

cnt = 1

for i in list:
    if is_prime(i):
        cnt += 1

print(cnt) import numpy as np numpy def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table divisor i = 1 i 1 table = [] table [] while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
     i * i <= n i * i i i n if n%i == 0:
            table.append(i)
            table.append(n//i)
         n%i == 0 n%i n i 0 table.append(i) table.append table append i table.append(n//i) table.append table append n//i n i i += 1 i 1 table = list(set(table)) table list(set(table)) list set(table) set table table = sorted(table) table sorted(table) sorted table return table table n n def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0] make_prime is_prime = np.zeros(U,np.bool) is_prime np.zeros(U,np.bool) np.zeros np zeros U np.bool np bool is_prime[2] = 1 is_prime[2] is_prime 2 1 is_prime[3::2] = 1 is_prime[3::2] is_prime 3::2 3 2 1 M = int(U**.5)+1 M int(U**.5)+1 int(U**.5) int U**.5 U .5 1 for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
     p range(3,M,2) range 3 M 2 if is_prime[p]:
            is_prime[p*p::p+p] = 0
     is_prime[p] is_prime p is_prime[p*p::p+p] = 0 is_prime[p*p::p+p] is_prime p*p::p+p p*p p p p+p p p 0 return is_prime, is_prime.nonzero()[0] return is_prime, is_prime.nonzero()[0] is_prime is_prime.nonzero()[0] is_prime.nonzero() is_prime.nonzero is_prime nonzero 0 U U A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True is_prime if n == 1:
        return False
     n == 1 n 1 return False False for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
     i range(2,int(n**0.5)+1) range 2 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n % i == 0:
            return False
     n % i == 0 n % i n i 0 return False False return True True n n A_list = set(divisor(A)) A_list set(divisor(A)) set divisor(A) divisor A B_list = set(divisor(B)) B_list set(divisor(B)) set divisor(B) divisor B list = A_list & B_list list A_list & B_list A_list B_list cnt = 1 cnt 1 for i in list:
    if is_prime(i):
        cnt += 1 i list if is_prime(i):
        cnt += 1 is_prime(i) is_prime i cnt += 1 cnt 1 print(cnt) print cnt list = A_list & B_list A_list & B_list list def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0] def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0] make_prime A_list = set(divisor(A)) set(divisor(A)) A_list B_list = set(divisor(B)) set(divisor(B)) B_list cnt += 1 1 cnt def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table divisor A, B = map(int, input().split()) map(int, input().split()) A B = map(int, input().split()) map(int, input().split()) B def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True is_prime cnt = 1 1 cnt
import numpy as np

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]
A, B = map(int, input().split())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

#_, primes = make_prime(10**8)

cnt = 1

for i in list:
    if is_prime(i):
        cnt += 1

print(cnt)