Problem:
 Score : 400 points    Problem Statement Given are positive integers A and B .  Let us choose some number of positive common divisors of A and B .  Here, any two of the chosen divisors must be coprime.  At most, how many divisors can we choose?  Definition of common divisor  An integer d is said to be a common divisor of integers x and y when d divides both x and y .   Definition of being coprime  Integers x and y are said to be coprime when x and y have no positive common divisors other than 1 .   Definition of dividing  An integer x is said to divide another integer y when there exists an integer \alpha such that y = \alpha x .       Constraints  All values in input are integers.  1 \leq A, B \leq 10^{12}         Input Input is given from Standard Input in the following format:  A  B       Output Print the maximum number of divisors that can be chosen to satisfy the condition.        Sample Input 1 12 18      Sample Output 1 3  12 and 18 have the following positive common divisors: 1 , 2 , 3 , and 6 .  1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1 , 2 , and 3 , which achieve the maximum result.       Sample Input 2 420 660      Sample Output 2 4       Sample Input 3 1 2019      Sample Output 3 1  1 and 2019 have no positive common divisors other than 1 .

Solution (Python):
def prime(n):
    memo = []
    for i in range(2,int(n**0.5)+1):
        while n%i == 0:
            memo.append(i)
            n //= i
    if n != 1:
        memo.append(n)
    return memo
        
    
a,b = map(int,input().split())    

aa = list(set(prime(a)))
bb = list(set(prime(b)))

count = 1

for i in aa:
    if i in bb:
        count += 1

print(count)

Solution (Python):
a,b = list(map(int,input().split()))
ad,bd = [],[]
for i in range(1,int(a**(1/2)) + 1):
    if a%i == 0:
        ad.append(i)
        ad.append(a//i)
for i in range(1,int(b**(1/2)) + 1):
    if b%i == 0:
        bd.append(i)
        bd.append(b//i)
cd = list(set(ad) & set(bd))
ans = []
def prime(n):
    if all(n%i!=0 for i in range(2,int(n**(1/2))+1)):
        return True
    else:
        return False
for num in cd:
    if prime(num):
        ans.append(num)
print(len(ans))

Solution (Python):
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = gcd ** 0.5
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)

Solution (Python):
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
if n == 1:
    print(1)
    exit()
count = 1
for i in range(2,math.ceil(math.sqrt(n))+1):
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
if n > 1:
    count += 1
print(count)

Solution (Python):
import math
import fractions

A,B = map(int,input().split())

g = fractions.gcd(A,B)

if g == 1:
    print(1)
    exit()

ans = 1

for i in range(2,math.floor(math.sqrt(g))+1):
    if g % i == 0:
        ans += 1
        while g % i == 0:
            g = g//i
if g != 1:
    ans += 1

print(ans)

Solution (Python):


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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



A, B = map(int, input().split())

fac_A = factorization(A)
fac_B = factorization(B)

prime_A = [f[0] for f in fac_A]
prime_B = [f[0] for f in fac_B]

if 1 in prime_A: prime_A.remove(1)
if 1 in prime_B: prime_B.remove(1)
common = set(prime_A) & set(prime_B)
print(len(common)+1)

Solution (Python):
import math
A, B = map( int, input().split() )

def euclid( A, B ):
  a = A
  b = B
  r = a % b
  while r != 0:
    a = b
    b = r
    r = a % b
  return b

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

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

    if ( n != 1 ) and ( arr == [] ):
        arr.append( n )

    return len( set( arr ) )

D = factorization( euclid( A, B ) )

print( D + 1 )

Solution (Python):
import math
A, B = map( int, input().split() )
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

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

    if ( n!=1 ) and ( arr==[] ):
        arr.append(n)

    return set( arr )

a = factorization(A)
b = factorization(B)
cnt = 0
for i in a:
  if i in b:
    cnt += 1

print( cnt + 1 )

Solution (Python):
a,b=map(int,input().split())
import fractions
g=fractions.gcd(a,b)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)
print(len(prime_factorize(g))+1)

Solution (Python):
import math
A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    i = 1
    while i <= math.sqrt(n):
        if n % i == 0:
            divisors.append(i)
            if i != math.sqrt(n):
                divisors.append(n // i)
        i += 1

    return divisors

def test_prime(n):
    if n == 1:
        return True
    i = 2
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 1
        
    return True
    
a_d = make_divisors(A)
b_d = make_divisors(B)

common_d = set(a_d) & set(b_d)

prime = 0

for c in common_d:
    if test_prime(c):
        prime += 1

print(prime)

Solution (Python):
import sys
input=sys.stdin.readline

















import fractions
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    def factorization(n): 
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
        if temp!=1:
            arr.append([temp, 1])
        if arr==[]:
            arr.append([n, 1])
        return arr
    c = fractions.gcd(A,B)
    arr = factorization(c)
    print(len(arr)+1)

Solution (Python):
import sys
input=sys.stdin.readline

















import fractions
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    def factorization(n): 
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
        if temp!=1:
            arr.append([temp, 1])
        if arr==[]:
            arr.append([n, 1])
        return arr
    c = fractions.gcd(A,B)
    arr = factorization(c)
    print(len(arr)+1)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from fractions import gcd
def prime_fact(m):
    pf={}
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    return list(pf)
def main():
    a,b=map(int,input().split())
    print(1+len(prime_fact(gcd(a,b))))

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from fractions import gcd
def prime_fact(m):
    pf={}
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    return list(pf)
def main():
    a,b=map(int,input().split())
    print(1+len(prime_fact(gcd(a,b))))

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
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

import math
def is_prime(n):
    if n==1:return False
    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False
    return True
    
def main():
    a,b=map(int,input().split())
    a_s,b_s=set(make_divisors(a)),set(make_divisors(b))
    c_s=a_s&b_s
    ans=[]
    c=list(c_s)
    c.sort()
    ans=1
    for cc in c:
        if is_prime(cc):
            ans+=1
    print(ans)


if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
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

import math
def is_prime(n):
    if n==1:return False
    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False
    return True
    
def main():
    a,b=map(int,input().split())
    a_s,b_s=set(make_divisors(a)),set(make_divisors(b))
    c_s=a_s&b_s
    ans=[]
    c=list(c_s)
    c.sort()
    ans=1
    for cc in c:
        if is_prime(cc):
            ans+=1
    print(ans)


if __name__=='__main__':
    main()

Solution (Python):
A, B = map(int, input().split())


def prime_factor(n):
    d = set()
    for i in range(2, n + 1):
        if i * i > n:
            break
        while n % i == 0:
            d.add(i)
            n //= i
            
    if n != 1:
        d.add(n)
    return d

a = prime_factor(A)
b = prime_factor(B)
print(len(set(a) & set(b)) + 1)

Solution (Python):
import fractions
a,b=map(int,input().split())
s=fractions.gcd(a,b)
cnt={1}
if s%2==0:
    cnt.add(2)
    while s%2==0:
      s//=2
for i in range(3,int(s**0.5)+1,2):
    if s%i==0:
        cnt.add(i)
        while s%i==0:
            s//=i
print(len(cnt)+(s>1))

Solution (Python):
def f(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return list(set(a))

import fractions
A,B=map(int,input().split())
gcd=fractions.gcd(A,B)
print(len(f(gcd)))

Solution (Python):

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def nC2(n):
    return n * (n - 1) // 2

a, b = map(int, input().split())

A = set(prime_factorize(a))
B = set(prime_factorize(b))

common = A & B
common.add(1)
ans = len(common)
print(ans)

Solution (Python):
A,B = (int(x) for x in input().split())
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = a & b
count = 1
if 2 in c:
    count += 1
for x in c:
    if x % 2 == 1:
        if len(make_divisors(x)) == 2:
            count += 1
print(count)

Solution (Python):
import fractions

A, B = map(int, input().split())

x = fractions.gcd(A, B)

C = []

def cal(i):
    for j in range(2, int(-(-i**0.5//1))+1):
        while True:
            if i%j == 0:
                i //= j
                C.append(j)
            else:
                break
    if i != 1:
        C.append(i)
        
    return set(C)

print(1+len(cal(x)))

Solution (Python):
import fractions
a,b=map(int,input().split())
k=fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    
    return arr

 
print(len(factorization(k))+1)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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)

    
    return divisors



def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime



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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr




a,b = myinput()
if a==1 and b==1:
    print(1)
    exit()

da = factorization(a)
db = factorization(b)



ls_a = []
for i in da:
    ls_a.append(i[0])

ls_b = []
for i in db:
    ls_b.append(i[0])




ls = list( set(ls_a) & set(ls_b) )
ans = len(ls) + 1
print(ans)

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    a, b = map(int,input().split())
    print(len(set(prime_factorize(gcd(a, b)))) + 1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
from fractions import gcd
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    res = prime_factorize(g)
    ans = len(res) + 1
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
from fractions import gcd
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    res = prime_factorize(g)
    ans = len(res) + 1
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
def prime_factor(n):
    ass = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass


a, b = map(int, input().split())
a_prime = set(prime_factor(a))
b_prime = set(prime_factor(b))
ab_prime = list(a_prime & b_prime)
print(len(ab_prime)+1)

Solution (Python):
def main():
    import fractions
    a,b = map(int,input().split())
    c = fractions.gcd(a,b)
    ans = [1]
    while c%2==0:
        c = c//2
        ans.append(2)
    f = 3
    while f*f<=c:
        if c%f==0:
            c = c//f
            ans.append(f) 
        else:
            f += 2
    if c!=1:
        ans.append(c)
    print(len(set(ans)))


if __name__ == "__main__":
    main()

Solution (Python):
def gcd(a,b): 
  while b:
    a,b=b,a%b
  return abs(a)
  
def solve(A:int, B:int):
  a=gcd(A,B)
  ap=a
  ct=0
  x=2
  if a%x==0:
    ct+=1
    while a%x==0:
      a=a//x
  
  x=3
  while x*x<ap+1:
    if a%x==0:
      ct+=1
      while a%x==0:
        a=a//x
    x+=2
  
  if a!=1:
    ct+=1
  print(ct+1)
  
  return

def main():
  A,B=map(int,input().split())
  solve(A,B)

if __name__=="__main__":
  main()

Solution (Python):
a, b = map(int, 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)

	return divisors
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True
yakua = make_divisors(a)
yakub = make_divisors(b)
s = set(yakua) & set(yakub)
ans = []
for i in list(s):
	if is_prime(i):
		ans.append(i)
print (len(ans)+1)

Solution (Python):
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

    counter_a = Counter(prime_factorize(a))
    counter_b = Counter(prime_factorize(b))

    c_a = list(counter_a.keys())
    c_b = list(counter_b.keys())

    count = len(set(c_a) & set(c_b))

    print(count+1)

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



def solve(A: int, B: int):
    a = gcd(A,B)
    ap = a
    ct = 0
    x = 2
    if a % x == 0:
        ct+=1
        while a % x == 0:
            a = a // x
    x = 3
    while x*x < ap+1: 
        if a % x == 0:
            ct+=1
            while a % x == 0:
                a = a // x
        x+=2
    
    if a != 1:
        ct +=1
    print(ct+1)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(A, B)

if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd
def prime_factorize_dict(n):
    d = dict()
    while not n & 1:
        d[2] = d.get(2, 0) + 1
        n >>= 1
    f = 3
    while f * f <= n:
        if not n % f:
            d[f] = d.get(f, 0) + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = d.get(n, 0) + 1
    return d

print(len(prime_factorize_dict(gcd(*map(int, input().split())))) + 1)

Solution (Python):
from statistics import median


from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b = readInts()
    from fractions import gcd
    g = gcd(a,b)
    
    i = 2
    A = defaultdict(int)
    while i * i <= g:
        if g % i == 0:
            A[i] += 1
            g //= i
        else:
            i += 1
    A[g] += 1
    ans = 1
    for k,v in A.items():
        if k != 1:
            ans += 1
    print(ans)
if __name__ == '__main__':
  main()

Solution (Python):
import sys
input = sys.stdin.readline().rstrip


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

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

    if arr == []:
        arr.append(n)
    arr.append(1)
    return set(arr)


def main():
    a, b = map(int, input().split())
    a = factorization(a)
    b = factorization(b)
    l = a & b
    print(len(l))


if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd
from collections import Counter

a, b = map(int, input().split())

gcd_ab = gcd(a, b)


def prime_factorize(n):
    res = 0
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m+1 if m == 2 else m+2
    if n>1:
        d[n] += 1
    return d


if gcd_ab == 1:  
    print(1)
    exit()


prime_d = prime_factorize(gcd_ab)
print(len(prime_d)+1)

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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a, b = map(int,input().split())
a, b = max(a,b), min(a,b)

r = -1
while r != 0:
    r = a%b
    a, b = b, r


if a == 1:
    print(1)
else:
    print(len(factorization(a))+1)

Solution (Python):
import math
def make_divisors(m, n):
    divisors = []
    numi = min(m, n)
    numa = max(m, n)
    for i in range(1, int(math.sqrt(numi)) + 1):
        if numi % i == 0:
            if numa % i == 0:
                divisors.append(i)
            
            if i != numi // i and numa % (numi // i) == 0:
                divisors.append(numi // i)
    return sorted(divisors)

a, b = map(int, input().split())
lista = make_divisors(a, b)
listb = [1]
lista.pop(0)
while len(lista) > 0:
    listb.append(lista[0])
    lista = [i for i in lista if i % lista[0] != 0]
print(len(listb))

Solution (Python):
from fractions import gcd
from math import sqrt


def prime_factorize(n):
    result = []
    for i in range(2, int(sqrt(n)) + 1):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


A, B = map(int, input().split())
print(len(prime_factorize(gcd(A, B))) + 1)

Solution (Python):
A, B = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def factorize(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr
n = gcd(A, B)
ans = factorize(n)
if ans[0][0] == 1:
    print(1)
else:
    print(len(ans)+1)

Solution (Python):
a,b=map(int,input().split())

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

c=fact(a)
d=fact(b)
e=[1]

  
for i in range(len(c)):
  if c[i]  in d:
    e.append(c[i])

e=set(e)    
print(len(e))

Solution (Python):
import math
A,B=[int(item) for item in input().split()]

def gdc(A,B):
    if A < B:
        A,B = B,A
    if B==0:
        return A
    else:
        A,B=B,A%B
        return gdc(A,B)

def chk_pn(num):
    flag=True
    if num <= 3:
        pass
    else:
        for i in range(2,int(math.sqrt(num))+1):
            if num % i ==0:
                flag = False
                break
    return flag
def mk_factor(num):
    max_divisor = int(math.sqrt(num))+1
    divisor =2
    factor_list=[1]

    while divisor <= max_divisor:
        if num % divisor ==0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1
    factor_list.append(num)
    return factor_list

GDC=gdc(A,B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]
print(len(set(pn_factor)))

Solution (Python):

"""nを素因数分解"""
"""2以上の整数n => [(素因数, 指数), ...]の2次元リスト"""


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

import fractions
a, b = map(int, input().split())
li = factorization(fractions.gcd(a, b))

if li[0][0] == 1:
    print(1)
else:
    print(len(li)+1)

Solution (Python):
from collections import Counter
from fractions import gcd
a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
g = gcd(a, b)
l = [1]
while g % 2 == 0:
    l.append(2)
    g /= 2
f = 3
while f * f <= g:
    if g % f == 0:
        l.append(f)
        g /= f
    else:
        f += 2
if g != 1:
    l.append(int(g))
cnt = Counter(l)
print(len(cnt))

Solution (Python):
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime

def input1():
	return int(input())


def input2():
	return map(int,input().split())


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

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets


def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	
	return fact(x+y)/fact(x)/fact(y)


def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			


A,B=input2()
gcd=fractions.gcd(A,B)

print(factorization(int(gcd))+1)

Solution (Python):
import fractions
import math
from collections import deque
A,B = list(map(int,input().split()))
gcd = fractions.gcd(A,B)
def gcd_another(N):
    R = deque()
    for i in range(1,math.ceil(int(N**0.5))+1):
        if N % i == 0:
            R.append(i)
            if i != N // i:
                R.append(N//i)
    R = list(R)
    R.sort()
    return R
C = gcd_another(gcd)
C.pop(0)
total = 1
while C != []:
    i = C[0]
    C = [j for j in C if j % i != 0]
    total += 1
print(total)

Solution (Python):
import random

A,B = map(int,input().split())

count = 0

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)

    
    return divisors

def is_prime3(q,k=50):
    q = abs(q)
    
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True


AL = make_divisors(A)
BL = make_divisors(B)

CS = set(AL) & set(BL)

for p in CS:
    if is_prime3(p):
        count += 1

print(count + 1)

Solution (Python):
from fractions import gcd
from math import floor, sqrt

a, b = [int(x) for x in input().split()]
c = gcd(a, b)

d_list = [1]
d = 2
stop = floor(sqrt(c))
while True:
    temp, mod = divmod(c, d)
    if mod == 0:
        d_list.append(d)
        c = temp
        stop = floor(sqrt(c))
    else:
        d += 1
    
    if stop < d:
        d_list.append(c)
        break

ans = len(set(d_list))
print(ans)

Solution (Python):
import fractions
A,B = map(int,input().split())
x = fractions.gcd(A,B)
pf = {}
for i in range(2,int(x**0.5)+2):
  while x%i == 0:
    pf[i] = pf.get(i,0) +1
    x //= i
if x > 1:
  pf[x] = 1
print(len(pf)+1)

Solution (Python):
a, b = map(int, input().split())
from fractions import gcd
from numpy import sqrt
m = gcd(a,b)
cnt = 1
for i in range(2, int(sqrt(m))+1):
    div = False
    while m%i == 0:
        div = True
        m = m//i
    if div:
        cnt += 1
    if m == 1:
        break
if m > 1:
    cnt += 1
print(cnt)

Solution (Python):

import io
import math
import heapq
import bisect

def f(n):
    res = set()
    for i in range(2, int(n ** 0.5)):
        if n % i: continue
        while not n % i: n //= i
        res.add(i)
    return res | {n}

nim, mike = map(int,input().split())
print(len(f(nim) & f(mike) | {1}))

Solution (Python):
p,q=map(int,input().split())
if q>p:
  p,q=q,p
  
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
  
def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
  
g=gcd(p,q)
res=prime_factorize(g)
print(len(res)+1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])

    prime = [1]
    for p in res:
        for _ in range(p[1]):
            prime.append(p[0])

    return prime


def resolve():
    a, b = map(int, input().split())
    A = prime_factorization(a)
    B = prime_factorization(b)

    res = set(A) & set(B)
    print(len(res))


if __name__ == '__main__':
    resolve()