import sys

input = sys.stdin.readline

import fractions

import math



def make_divisors(n):

    divisors = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    divisors.sort()

    return divisors



def main():

    A, B = [int(x) for x in input().split()]

    x = fractions.gcd(A, B)

    divisors = make_divisors(x)



    ans = 0

    for k in divisors:

        if k == 1:

            ans += 1

            continue



        factor = 0

        if k % 2 == 0 and k != 2:

            continue



        # 繰り返しの上限を対象の平方根にする

        for x in range(2, math.floor(math.sqrt(k)) + 1):

            if k % x == 0:

                factor += 1



        if factor == 0:

            ans += 1



    print(ans)







if __name__ == '__main__':

    main()



A, B = [int(x) for x in input().split()]



def prime_factorization(n):

    i = 2

    factors = []

    while i * i <= n:

        if n % i:

            i += 1

        else:

            n //= i

            factors.append(i)

    if n > 1:

        factors.append(n)

    return factors



Aprimes = prime_factorization(A)

Bprimes = set(prime_factorization(B))



ans = 1

ansset = set()

for a in Aprimes:

    if a in ansset:

        continue

    if a in Bprimes:

        ansset.add(a)

        ans += 1



print(ans)



import sys

input = sys.stdin.readline
import fractions
import math


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


def main():
    A, B = [int(x) for x in input().split()]
    x = fractions.gcd(A, B)
    divisors = make_divisors(x)
    ans = 0
    for k in divisors:
        if k == 1:
            ans += 1
            continue
        factor = 0
        if k % 2 == 0 and k != 2:
            continue
        # 繰り返しの上限を対象の平方根にする
        for x in range(2, math.floor(math.sqrt(k)) + 1):
            if k % x == 0:
                factor += 1
        if factor == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

A, B = [int(x) for x in input().split()]


def prime_factorization(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


Aprimes = prime_factorization(A)
Bprimes = set(prime_factorization(B))
ans = 1
ansset = set()
for a in Aprimes:
    if a in ansset:
        continue
    if a in Bprimes:
        ansset.add(a)
        ans += 1
print(ans)

-import sys - -input = sys.stdin.readline -import fractions -import math +A, B = [int(x) for x in input().split()] -def make_divisors(n): -    divisors = [] -    for i in range(1, int(n**0.5) + 1): -        if n % i == 0: -            divisors.append(i) -            if i != n // i: -                divisors.append(n // i) -    divisors.sort() -    return divisors +def prime_factorization(n): +    i = 2 +    factors = [] +    while i * i <= n: +        if n % i: +            i += 1 +        else: +            n //= i +            factors.append(i) +    if n > 1: +        factors.append(n) +    return factors -def main(): -    A, B = [int(x) for x in input().split()] -    x = fractions.gcd(A, B) -    divisors = make_divisors(x) -    ans = 0 -    for k in divisors: -        if k == 1: -            ans += 1 -            continue -        factor = 0 -        if k % 2 == 0 and k != 2: -            continue -        # 繰り返しの上限を対象の平方根にする -        for x in range(2, math.floor(math.sqrt(k)) + 1): -            if k % x == 0: -                factor += 1 -        if factor == 0: -            ans += 1 -    print(ans) - - -if __name__ == "__main__": -    main() +Aprimes = prime_factorization(A) +Bprimes = set(prime_factorization(B)) +ans = 1 +ansset = set() +for a in Aprimes: +    if a in ansset: +        continue +    if a in Bprimes: +        ansset.add(a) +        ans += 1 +print(ans)