
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True  
a,b = map(int,input().split())
a_list = make_divisors(a)
b_list = make_divisors(b)
a_b_and = set(a_list) & set(b_list)
a_b_and = list(a_b_and)


count = 1
for a_b in a_b_and:
  if is_prime(a_b) == True:
    count += 1
    
print(count) def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors make_divisors divisors = [] divisors [] for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
     i range(1, int(n**0.5)+1) range 1 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
     n % i == 0 n % i n i 0 divisors.append(i) divisors.append divisors append i if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
     i != n // i i n // i n i divisors.append(n//i) divisors.append divisors append n//i n i return divisors divisors n n import math math def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True   is_prime if n == 1: return False

     n == 1 n 1 for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

     k range(2, int(math.sqrt(n)) + 1) range 2 int(math.sqrt(n)) + 1 int(math.sqrt(n)) int math.sqrt(n) math.sqrt math sqrt n 1 if n % k == 0:
            return False

     n % k == 0 n % k n k 0 return False False return True True n n a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b a_list = make_divisors(a) a_list make_divisors(a) make_divisors a b_list = make_divisors(b) b_list make_divisors(b) make_divisors b a_b_and = set(a_list) & set(b_list) a_b_and set(a_list) & set(b_list) set(a_list) set a_list set(b_list) set b_list a_b_and = list(a_b_and) a_b_and list(a_b_and) list a_b_and count = 1 count 1 for a_b in a_b_and:
  if is_prime(a_b) == True:
    count += 1
     a_b a_b_and if is_prime(a_b) == True:
    count += 1
     is_prime(a_b) == True is_prime(a_b) is_prime a_b True count += 1 count 1 print(count) print count a_list = make_divisors(a) make_divisors(a) a_list b_list = make_divisors(b) make_divisors(b) b_list a_b_and = set(a_list) & set(b_list) set(a_list) & set(b_list) a_b_and count = 1 1 count def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors make_divisors b = map(int,input().split()) map(int,input().split()) b count += 1 1 count a,b = map(int,input().split()) map(int,input().split()) a a_b_and = list(a_b_and) list(a_b_and) a_b_and def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True   def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True   is_prime

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True  
a,b = map(int,input().split())
a_list = make_divisors(a)
b_list = make_divisors(b)
a_b_and = set(a_list) & set(b_list)
a_b_and = list(a_b_and)


count = 1
for a_b in a_b_and:
  if is_prime(a_b) == True:
    count += 1
    
print(count)