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 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, B = map(int, input().split())

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

list = A_list & B_list

cnt = 1

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

print(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 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 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, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B 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 B = map(int, input().split()) map(int, input().split()) B cnt += 1 1 cnt list = A_list & B_list A_list & B_list list cnt = 1 1 cnt 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 A, B = map(int, input().split()) map(int, input().split()) A 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 B_list = set(divisor(B)) set(divisor(B)) B_list A_list = set(divisor(A)) set(divisor(A)) A_list
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 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, B = map(int, input().split())

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

list = A_list & B_list

cnt = 1

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

print(cnt)