from sys import stdin, setrecursionlimit


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


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


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    g = gcd(a, b)

    ans = 0

    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main() from sys import stdin, setrecursionlimit def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y) gcd if x % y == 0:
        return y
     x % y == 0 x % y x y 0 return y y return gcd(y, x % y) gcd(y, x % y) gcd y x % y x y x x y y def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True is_prime if n == 1:
        return False
     n == 1 n 1 return False False for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
     i range(2, int(n ** 0.5) + 1) range 2 int(n ** 0.5) + 1 int(n ** 0.5) int n ** 0.5 n 0.5 1 if n % i == 0:
            return False
     n % i == 0 n % i n i 0 return False False return True True n n def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    g = gcd(a, b)

    ans = 0

    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

    print(ans) main input = stdin.buffer.readline input stdin.buffer.readline stdin.buffer stdin buffer readline a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b g = gcd(a, b) g gcd(a, b) gcd a b ans = 0 ans 0 for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

     i range(1, int(g ** 0.5) + 1) range 1 int(g ** 0.5) + 1 int(g ** 0.5) int g ** 0.5 g 0.5 1 if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

     g % i == 0 g % i g i 0 if is_prime(i) or i == 1:
                ans += 1
             is_prime(i) or i == 1 is_prime(i) is_prime i i == 1 i 1 ans += 1 ans 1 if is_prime(g // i) and i != g // i:
                ans += 1

     is_prime(g // i) and i != g // i is_prime(g // i) is_prime g // i g i i != g // i i g // i g i ans += 1 ans 1 print(ans) print ans if __name__ == "__main__":
    setrecursionlimit(10000)
    main() __name__ == "__main__" __name__ "__main__" setrecursionlimit(10000) setrecursionlimit 10000 main() main def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    g = gcd(a, b)

    ans = 0

    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

    print(ans) def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    g = gcd(a, b)

    ans = 0

    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

    print(ans) main def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y) def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y) gcd def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True is_prime
from sys import stdin, setrecursionlimit


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


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


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    g = gcd(a, b)

    ans = 0

    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
