def factorize(N):
    if N == 1: return {1:1}
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res

A, B = map(int, input().split())
resA = factorize(A)
resB = factorize(B)
res = set(resA.keys()) & set(resB.keys())
ans = len(res) if 1 in res else len(res)+1
print(ans) def factorize(N):
    if N == 1: return {1:1}
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res factorize if N == 1: return {1:1}
     N == 1 N 1 res = {} res {} for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
     i range(2, N) range 2 N if i**2 > N: break
         i**2 > N i**2 i 2 N if N % i != 0: continue
         N % i != 0 N % i N i 0 num = 0 num 0 while N % i == 0:
            N = int(N/i)
            num += 1
         N % i == 0 N % i N i 0 N = int(N/i) N int(N/i) int N/i N i num += 1 num 1 res[i] = num res[i] res i num if N>1: res[N] = 1
     N>1 N 1 return res res N N A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B resA = factorize(A) resA factorize(A) factorize A resB = factorize(B) resB factorize(B) factorize B res = set(resA.keys()) & set(resB.keys()) res set(resA.keys()) & set(resB.keys()) set(resA.keys()) set resA.keys() resA.keys resA keys set(resB.keys()) set resB.keys() resB.keys resB keys ans = len(res) if 1 in res else len(res)+1 ans len(res) if 1 in res else len(res)+1 1 in res 1 res len(res) len res len(res)+1 len(res) len res 1 print(ans) print ans resB = factorize(B) factorize(B) resB B = map(int, input().split()) map(int, input().split()) B resA = factorize(A) factorize(A) resA def factorize(N):
    if N == 1: return {1:1}
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res def factorize(N):
    if N == 1: return {1:1}
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res factorize A, B = map(int, input().split()) map(int, input().split()) A res = set(resA.keys()) & set(resB.keys()) set(resA.keys()) & set(resB.keys()) res ans = len(res) if 1 in res else len(res)+1 len(res) if 1 in res else len(res)+1 ans
def factorize(N):
    if N == 1: return {1:1}
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res

A, B = map(int, input().split())
resA = factorize(A)
resB = factorize(B)
res = set(resA.keys()) & set(resB.keys())
ans = len(res) if 1 in res else len(res)+1
print(ans)