from math import gcd
from copy import copy
a, b = map(int, input().split())

def div(x):
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
    return ret

def judge_prime(x):
    cnt = 0
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            cnt += 1
        if cnt >= 2:
            return False
    return True

div_a = div(a)
div_b = div(b)

data = list(set(div_a) & set(div_b))

ans = 0
for x in data:
    if judge_prime(x):
        ans += 1
print(ans) from math import gcd from copy import copy a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b def div(x):
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
    return ret div ret = [] ret [] for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
     i range(1, int(x ** 0.5) + 1) range 1 int(x ** 0.5) + 1 int(x ** 0.5) int x ** 0.5 x 0.5 1 if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
     x % i == 0 x % i x i 0 ret.append(i) ret.append ret append i ret.append(x // i) ret.append ret append x // i x i return ret ret x x def judge_prime(x):
    cnt = 0
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            cnt += 1
        if cnt >= 2:
            return False
    return True judge_prime cnt = 0 cnt 0 for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            cnt += 1
        if cnt >= 2:
            return False
     i range(1, int(x ** 0.5) + 1) range 1 int(x ** 0.5) + 1 int(x ** 0.5) int x ** 0.5 x 0.5 1 if x % i == 0:
            cnt += 1
         x % i == 0 x % i x i 0 cnt += 1 cnt 1 if cnt >= 2:
            return False
     cnt >= 2 cnt 2 return False False return True True x x div_a = div(a) div_a div(a) div a div_b = div(b) div_b div(b) div b data = list(set(div_a) & set(div_b)) data list(set(div_a) & set(div_b)) list set(div_a) & set(div_b) set(div_a) set div_a set(div_b) set div_b ans = 0 ans 0 for x in data:
    if judge_prime(x):
        ans += 1 x data if judge_prime(x):
        ans += 1 judge_prime(x) judge_prime x ans += 1 ans 1 print(ans) print ans def div(x):
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
    return ret def div(x):
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
    return ret div data = list(set(div_a) & set(div_b)) list(set(div_a) & set(div_b)) data a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b ans += 1 1 ans div_b = div(b) div(b) div_b ans = 0 0 ans div_a = div(a) div(a) div_a def judge_prime(x):
    cnt = 0
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            cnt += 1
        if cnt >= 2:
            return False
    return True def judge_prime(x):
    cnt = 0
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            cnt += 1
        if cnt >= 2:
            return False
    return True judge_prime
from math import gcd
from copy import copy
a, b = map(int, input().split())

def div(x):
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    
    return ret

def judge_prime(x):
    cnt = 0
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            cnt += 1
        if cnt >= 2:
            return False
    return True

div_a = div(a)
div_b = div(b)

data = list(set(div_a) & set(div_b))

ans = 0
for x in data:
    if judge_prime(x):
        ans += 1
print(ans)