def factorization(n):
    factorization_list = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

    if temp != 1:
        factorization_list.append(temp)

    if factorization_list==[]:
        factorization_list.append(n)

    return factorization_list


if __name__ == "__main__":
    A, B = map(int, input().split())
    A_fac = set(factorization(A))
    B_fac = set(factorization(B))

    AB_fac = A_fac & B_fac
    print(len(AB_fac)) def factorization(n):
    factorization_list = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

    if temp != 1:
        factorization_list.append(temp)

    if factorization_list==[]:
        factorization_list.append(n)

    return factorization_list factorization factorization_list = [1] factorization_list [1] 1 temp = n temp n for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

     i range(2, int(-(-n**0.5//1))+1) range 2 int(-(-n**0.5//1))+1 int(-(-n**0.5//1)) int -(-n**0.5//1) -n**0.5//1 -n**0.5 n**0.5 n 0.5 1 1 if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

     temp % i == 0 temp % i temp i 0 count = 0 count 0 while temp % i == 0:
                count += 1
                temp //= i
             temp % i == 0 temp % i temp i 0 count += 1 count 1 temp //= i temp i factorization_list.append(i) factorization_list.append factorization_list append i if temp != 1:
        factorization_list.append(temp)

     temp != 1 temp 1 factorization_list.append(temp) factorization_list.append factorization_list append temp if factorization_list==[]:
        factorization_list.append(n)

     factorization_list==[] factorization_list [] factorization_list.append(n) factorization_list.append factorization_list append n return factorization_list factorization_list n n if __name__ == "__main__":
    A, B = map(int, input().split())
    A_fac = set(factorization(A))
    B_fac = set(factorization(B))

    AB_fac = A_fac & B_fac
    print(len(AB_fac)) __name__ == "__main__" __name__ "__main__" A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B A_fac = set(factorization(A)) A_fac set(factorization(A)) set factorization(A) factorization A B_fac = set(factorization(B)) B_fac set(factorization(B)) set factorization(B) factorization B AB_fac = A_fac & B_fac AB_fac A_fac & B_fac A_fac B_fac print(len(AB_fac)) print len(AB_fac) len AB_fac B_fac = set(factorization(B)) set(factorization(B)) B_fac B = map(int, input().split()) map(int, input().split()) B A, B = map(int, input().split()) map(int, input().split()) A AB_fac = A_fac & B_fac A_fac & B_fac AB_fac A_fac = set(factorization(A)) set(factorization(A)) A_fac def factorization(n):
    factorization_list = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

    if temp != 1:
        factorization_list.append(temp)

    if factorization_list==[]:
        factorization_list.append(n)

    return factorization_list def factorization(n):
    factorization_list = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

    if temp != 1:
        factorization_list.append(temp)

    if factorization_list==[]:
        factorization_list.append(n)

    return factorization_list factorization
def factorization(n):
    factorization_list = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            factorization_list.append(i)

    if temp != 1:
        factorization_list.append(temp)

    if factorization_list==[]:
        factorization_list.append(n)

    return factorization_list


if __name__ == "__main__":
    A, B = map(int, input().split())
    A_fac = set(factorization(A))
    B_fac = set(factorization(B))

    AB_fac = A_fac & B_fac
    print(len(AB_fac))