import math

A, B = list(map(int, input().split()))
count = 0

def divisor(x):
    divs = []
    for i in range(1, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            divs.append(i)
            if i**2 != x:
                divs.append(x//i)
    return divs

def evPrimal(x):
    if x < 4:
        return True
    divs = []
    for i in range(2, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            return False
    return True

codiv = set(divisor(A)) & set(divisor(B))

for i in codiv:
    if evPrimal(i):
        count += 1

print(count) import math math A, B = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B count = 0 count 0 def divisor(x):
    divs = []
    for i in range(1, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            divs.append(i)
            if i**2 != x:
                divs.append(x//i)
    return divs divisor divs = [] divs [] for i in range(1, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            divs.append(i)
            if i**2 != x:
                divs.append(x//i)
     i range(1, math.floor(math.sqrt(x))+1) range 1 math.floor(math.sqrt(x))+1 math.floor(math.sqrt(x)) math.floor math floor math.sqrt(x) math.sqrt math sqrt x 1 if x%i == 0:
            divs.append(i)
            if i**2 != x:
                divs.append(x//i)
     x%i == 0 x%i x i 0 divs.append(i) divs.append divs append i if i**2 != x:
                divs.append(x//i)
     i**2 != x i**2 i 2 x divs.append(x//i) divs.append divs append x//i x i return divs divs x x def evPrimal(x):
    if x < 4:
        return True
    divs = []
    for i in range(2, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            return False
    return True evPrimal if x < 4:
        return True
     x < 4 x 4 return True True divs = [] divs [] for i in range(2, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            return False
     i range(2, math.floor(math.sqrt(x))+1) range 2 math.floor(math.sqrt(x))+1 math.floor(math.sqrt(x)) math.floor math floor math.sqrt(x) math.sqrt math sqrt x 1 if x%i == 0:
            return False
     x%i == 0 x%i x i 0 return False False return True True x x codiv = set(divisor(A)) & set(divisor(B)) codiv set(divisor(A)) & set(divisor(B)) set(divisor(A)) set divisor(A) divisor A set(divisor(B)) set divisor(B) divisor B for i in codiv:
    if evPrimal(i):
        count += 1 i codiv if evPrimal(i):
        count += 1 evPrimal(i) evPrimal i count += 1 count 1 print(count) print count def evPrimal(x):
    if x < 4:
        return True
    divs = []
    for i in range(2, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            return False
    return True def evPrimal(x):
    if x < 4:
        return True
    divs = []
    for i in range(2, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            return False
    return True evPrimal B = list(map(int, input().split())) list(map(int, input().split())) B def divisor(x):
    divs = []
    for i in range(1, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            divs.append(i)
            if i**2 != x:
                divs.append(x//i)
    return divs def divisor(x):
    divs = []
    for i in range(1, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            divs.append(i)
            if i**2 != x:
                divs.append(x//i)
    return divs divisor codiv = set(divisor(A)) & set(divisor(B)) set(divisor(A)) & set(divisor(B)) codiv count += 1 1 count A, B = list(map(int, input().split())) list(map(int, input().split())) A count = 0 0 count
import math

A, B = list(map(int, input().split()))
count = 0

def divisor(x):
    divs = []
    for i in range(1, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            divs.append(i)
            if i**2 != x:
                divs.append(x//i)
    return divs

def evPrimal(x):
    if x < 4:
        return True
    divs = []
    for i in range(2, math.floor(math.sqrt(x))+1):
        if x%i == 0:
            return False
    return True

codiv = set(divisor(A)) & set(divisor(B))

for i in codiv:
    if evPrimal(i):
        count += 1

print(count)