from math import gcd
from itertools import combinations


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


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


a, b = map(int, input().split())
se = set(make_divisors(a)) & set(make_divisors(b))
ans = 1
for i in se:
    if is_prime(i):
        ans += 1
print(ans) from math import gcd from itertools import combinations def make_divisors(n):
    divisors = []
    for i in range(1, int(n**.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors make_divisors divisors = [] divisors [] for i in range(1, int(n**.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
     i range(1, int(n**.5)+1) range 1 int(n**.5)+1 int(n**.5) int n**.5 n .5 1 if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
     n % i == 0 n % i n i 0 divisors.append(i) divisors.append divisors append i if i != n // i:
                divisors.append(n//i)
     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 def is_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p**.5) + 1):
        if p % i == 0:
            return False
    return True is_prime if p == 1:
        return False
     p == 1 p 1 return False False for i in range(2, int(p**.5) + 1):
        if p % i == 0:
            return False
     i range(2, int(p**.5) + 1) range 2 int(p**.5) + 1 int(p**.5) int p**.5 p .5 1 if p % i == 0:
            return False
     p % i == 0 p % i p i 0 return False False return True True p p a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b se = set(make_divisors(a)) & set(make_divisors(b)) se set(make_divisors(a)) & set(make_divisors(b)) set(make_divisors(a)) set make_divisors(a) make_divisors a set(make_divisors(b)) set make_divisors(b) make_divisors b ans = 1 ans 1 for i in se:
    if is_prime(i):
        ans += 1 i se if is_prime(i):
        ans += 1 is_prime(i) is_prime i ans += 1 ans 1 print(ans) print ans se = set(make_divisors(a)) & set(make_divisors(b)) set(make_divisors(a)) & set(make_divisors(b)) se ans += 1 1 ans b = map(int, input().split()) map(int, input().split()) b def make_divisors(n):
    divisors = []
    for i in range(1, int(n**.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors def make_divisors(n):
    divisors = []
    for i in range(1, int(n**.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors make_divisors def is_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p**.5) + 1):
        if p % i == 0:
            return False
    return True def is_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p**.5) + 1):
        if p % i == 0:
            return False
    return True is_prime a, b = map(int, input().split()) map(int, input().split()) a ans = 1 1 ans
from math import gcd
from itertools import combinations


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


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


a, b = map(int, input().split())
se = set(make_divisors(a)) & set(make_divisors(b))
ans = 1
for i in se:
    if is_prime(i):
        ans += 1
print(ans)
