import math

def divisors(x):
    l = [[], []]
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
    return l[0]+l[1][::-1]

def primenumber(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True

a, b = map(int, input().split())
cnt = 0
for i in divisors(math.gcd(a, b)):
    if i == 1:
        cnt += 1
    elif primenumber(i):
        cnt += 1
print(cnt) import math math def divisors(x):
    l = [[], []]
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
    return l[0]+l[1][::-1] divisors l = [[], []] l [[], []] [] [] for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
     i range(1, int(math.sqrt(x))+1) range 1 int(math.sqrt(x))+1 int(math.sqrt(x)) int math.sqrt(x) math.sqrt math sqrt x 1 if x % i == 0:
            if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
     x % i == 0 x % i x i 0 if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
     i**2 != x i**2 i 2 x l[0].append(i) [0].append [0] l 0 append i l[1].append(x//i) [1].append [1] l 1 append x//i x i l[0].append(i) [0].append [0] l 0 append i return l[0]+l[1][::-1] l[0]+l[1][::-1] l[0] l 0 l[1][::-1] [1] l 1 ::-1 -1 x x def primenumber(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True primenumber for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
     i range(2, int(math.sqrt(x))+1) range 2 int(math.sqrt(x))+1 int(math.sqrt(x)) int 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 a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b cnt = 0 cnt 0 for i in divisors(math.gcd(a, b)):
    if i == 1:
        cnt += 1
    elif primenumber(i):
        cnt += 1 i divisors(math.gcd(a, b)) divisors math.gcd(a, b) math.gcd math gcd a b if i == 1:
        cnt += 1
    elif primenumber(i):
        cnt += 1 i == 1 i 1 cnt += 1 cnt 1 elif primenumber(i):
        cnt += 1 primenumber(i) primenumber i cnt += 1 cnt 1 print(cnt) print cnt def primenumber(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True def primenumber(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True primenumber cnt = 0 0 cnt a, b = map(int, input().split()) map(int, input().split()) a cnt += 1 1 cnt cnt += 1 1 cnt b = map(int, input().split()) map(int, input().split()) b def divisors(x):
    l = [[], []]
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
    return l[0]+l[1][::-1] def divisors(x):
    l = [[], []]
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
    return l[0]+l[1][::-1] divisors
import math

def divisors(x):
    l = [[], []]
    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            if i**2 != x:
                l[0].append(i)
                l[1].append(x//i)
            else:
                l[0].append(i)
    return l[0]+l[1][::-1]

def primenumber(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False
    return True

a, b = map(int, input().split())
cnt = 0
for i in divisors(math.gcd(a, b)):
    if i == 1:
        cnt += 1
    elif primenumber(i):
        cnt += 1
print(cnt)