def input_li():
    return list(map(int, input().split()))


def input_int():
    return int(input())


def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


A, B = input_li()
A_SET = set(prime_factorization(A))
B_SET = set(prime_factorization(B))
print(len(A_SET & B_SET) + 1) def input_li():
    return list(map(int, input().split())) input_li return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def input_int():
    return int(input()) input_int return int(input()) int(input()) int input() input def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table prime_factorization table = [] table [] for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
     x 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 while n % x == 0:
            table.append(x)
            n //= x
     n % x == 0 n % x n x 0 table.append(x) table.append table append x n //= x n x if n > 1:
        table.append(n)
     n > 1 n 1 table.append(n) table.append table append n return table table n n A, B = input_li() A input_li() input_li B A_SET = set(prime_factorization(A)) A_SET set(prime_factorization(A)) set prime_factorization(A) prime_factorization A B_SET = set(prime_factorization(B)) B_SET set(prime_factorization(B)) set prime_factorization(B) prime_factorization B print(len(A_SET & B_SET) + 1) print len(A_SET & B_SET) + 1 len(A_SET & B_SET) len A_SET & B_SET A_SET B_SET 1 B_SET = set(prime_factorization(B)) set(prime_factorization(B)) B_SET B = input_li() input_li() B A, B = input_li() input_li() A def input_li():
    return list(map(int, input().split())) def input_li():
    return list(map(int, input().split())) input_li A_SET = set(prime_factorization(A)) set(prime_factorization(A)) A_SET def input_int():
    return int(input()) def input_int():
    return int(input()) input_int def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table prime_factorization
def input_li():
    return list(map(int, input().split()))


def input_int():
    return int(input())


def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


A, B = input_li()
A_SET = set(prime_factorization(A))
B_SET = set(prime_factorization(B))
print(len(A_SET & B_SET) + 1)
