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):
from fractions import gcd

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())
c = gcd(a, b)
fact = factorization(c)
if fact[0][0] == 1:
    print(1)
else:
    print(len(fact) + 1)

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

def is_prime(num):
    if num<1:
        return False
    if num==1 or num==2 or num==3:
        return True
    for i in range(2,int(num**0.5)+1):
        if num%i==0:
            return False
    return True
 
def main():
    a,b=map(int,input().split())
    GCD=gcd(a,b)
    ans=0
    for i in range(1,int(GCD**0.5)+1):
        if GCD%i==0:
            if is_prime(i):
                ans+=1
            if i!=GCD and is_prime(GCD//i):
                ans+=1
    print(ans)
    
main()

Solution (Python):

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


def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1



ans = 1
temp1 = divisor(a)
temp2 = divisor(b)
hoge = []
if len(temp1) < len(temp2):
    hoge = temp1
    hoge2 = temp2
else:
    hoge = temp2
    hoge2 = temp1

temp = []
for i in hoge:
    if i in hoge2:
        temp.append(i)


for i in temp:
    if is_prime(i):
        ans += 1

print (ans)

Solution (Python):
a=input().split(" ")
A=int(a[0])
B=int(a[1])
if A<B:
    A,B=B,A
while A%B!=0:
    A,B=B,A%B
if B==1:
    print(1)
else:
    count=1
    i=2
    while i**2<=B:
        if B%i==0:
            count+=1
            while B%i==0:
                B/=i
        i+=1
    if B!=1:
        count+=1
    print(count)

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

def factorize(n):
	b = 2
	factor = []
	while b * b <= n:
		while n % b == 0:
			n //= b
			factor.append(b)
		b = b + 1
	if n > 1:
		factor.append(n)
	
	factor = set(factor)
	return factor
    
pryA = factorize(A)
pryB = factorize(B)
 
com = (pryA & pryB)

print(len(com) + 1)

Solution (Python):
a, b = map(int, input().split(' '))
 
def divisor(n):
  ass = []
  for i in range(1,int(n**0.5)+1):
    if n%i == 0:
      ass.append(i)
      ass.append(n//i)
  return ass 
 
a_div = divisor(a)
b_div = divisor(b)

k = []
for val in a_div:
  if val != 1 and val in b_div:
    k.append(val)
k.sort()

ans = 0
if len(k) == 0:
  ans = 1
elif len(k) == 1:
  ans = 2
else:
  ans = 2
  for i in range(1, len(k)):
    tmp = k[i]
    for j in range(0, i):
      if (tmp % k[j]) == 0:
        break
    else:
      ans += 1
 
print(ans)

Solution (Python):
a,b=map(int,input().split())
import fractions
n=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])

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

    return arr

if factorization(n)==[[1,1]]:
  print(1)
else:
  print(len(factorization(n))+1)

Solution (Python):
import fractions
a,b = list(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, cnt])

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

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

    return arr
res = dict(factorization(fractions.gcd(a,b)))
res[1] = 1
print(len(res))

Solution (Python):
import fractions


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

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

div_a = make_divisors(a)
div_a.sort()



div_b = make_divisors(b)
div_b.sort()



ans = 0
a_inc = 0
b_inc = 0
ans_list = []
"""
for i in range(len(div_a)):
    while i+a_inc < len(div_a) and i+b_inc < len(div_b):
        if div_a[i+a_inc] == div_b[i+b_inc]:
            ans += 1
            ans_list.append(div_a[i+a_inc])
            break
        elif div_a[i+a_inc] > div_b[i+b_inc]:
            b_inc += 1
        else:
            a_inc += 1
"""

while a_inc < len(div_a) and b_inc < len(div_b):
    if div_a[a_inc] == div_b[b_inc]:
        ans += 1
        ans_list.append(div_a[a_inc])
        b_inc += 1
        a_inc += 1
    elif div_a[a_inc] > div_b[b_inc]:
        b_inc += 1
    else:
        a_inc += 1


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

a_list = []
a_list.append(ans_list[1])

for i in range(2,ans):
    for j in range(len(a_list)):
        if ans_list[i] % a_list[j] == 0:
            break
        if j == len(a_list)-1:
            a_list.append(ans_list[i])

print(len(a_list)+1)

Solution (Python):
a, b = map(int, open(0).read().split())

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

prime_a = set(prime_factorize(a))
prime_b = set(prime_factorize(b))
print(len(prime_a&prime_b)+1)

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(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

A,B=two_int()

data = list(set(make_divisors(A)) & set(make_divisors(B)))

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

count=1
data.sort()
for i in data[1:]:
    if is_prime(i):
        count+=1
print(count)

Solution (Python):
import fractions
import numpy
import sys

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())
g = fractions.gcd(a, b)

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

print(len(factorization(g)) + 1)

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

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

def coprime(a, b):
    return gcd(a, b) == 1
 
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

cmlist = sorted(list(set(divisor(A)) & set(divisor(B))))
res = []
for cm1 in cmlist:
  can_append = True
  for cm2 in res:
    if not coprime(cm1, cm2):
      can_append = False
      continue
  if can_append:
    res.append(cm1)
print(len(res))

Solution (Python):
import math
import queue
import bisect
import heapq
import time

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b): 
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): 
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): 
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): 
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    g_l = divisors(g)
    ans = 1
    for i in g_l:
        if is_prime(i):
            ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    A,B = map(int,input().split())
    import fractions
    C = fractions.gcd(A,B)
    cnt = 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_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    C_2 = make_divisors(C)
    
    for i in C_2:
        if is_prime(i):
            cnt += 1
    print(cnt)
    
    


    
if __name__ == '__main__':
    main()

Solution (Python):

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

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

n1 = make_divisors(A)
n2 = make_divisors(B)

answer = 0
n1_n2_set = set(n1) & set(n2)
n1_n2_list = list(n1_n2_set)
common_fractions = sorted(n1_n2_list)

varL = []
for i in range(len(common_fractions)):
  varsum = 0
  if len(varL) >= 1:
    for j in range(len(varL)):
      
      if fractions.gcd(common_fractions[i], varL[j]) != 1:
        varsum += 1
    if varsum == 0:
      answer += 1
      varL.append(common_fractions[i])
  else:
    varL.append(common_fractions[i])
    answer += 1

print(answer)

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

def gcd(a,b):
    r = divmod(a,b)[1]
    if r == 0:
        return int(b)
    else:
        return gcd(b,r)

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


print(len(list(set(fact(gcd(A,B)))))+1)

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

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

a, b = map(int, input().split())
g = gcd(a, b) 
if g == 1:
    print(1)
    sys.exit()

li = [1]
true_li = make_divisors(g)


for i in true_li:
    if i == 1:
        continue
    count = 0
    for l in li:
        if gcd(l,i) != 1:
            count += 1
    if count == 0:
        li.append(i)
print(len(li))

Solution (Python):
A, B = map(int,input().split())
import fractions
_gcd = fractions.gcd(A, B)

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

l = make_divisors(_gcd)
if len(l)==1:
    print(1)
    quit()
l.sort()
aa=False
for x in l:
    if x%2==0:
        aa=x
        break
if aa:
    l2 = [x for x in l if x%2]
    l2.append(aa)
else:
    l2 = l[:]
for i,x in enumerate(l2):
    for y in l2[i+1:]:
        if fractions.gcd(x, y) != 1 and y in l2:
            l2.remove(y)
print(len(l2))

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


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


if a > b:
    num = gcd(a, b)
else:
    num = gcd(b, a)


def prime(n):
    i = 2
    table = set([])
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.add(i)
        i += 1
    if n > 1:
        table.add(n)
    return len(table)


print(prime(num)+1)

Solution (Python):
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 fractions
a,b=map(int,input().split())
gcd = fractions.gcd(a,b)


pnum = set()

if gcd == 1:
    print(1)
elif gcd == 2:
    print(2)
else:
    devlist = make_divisors(gcd)
    
    
    
    for num in devlist:
        if (num!=1):
            
            ptf = True
            for p in pnum:
                if num%p==0:
                    ptf = False
                    break
            if ptf ==True:
                pnum.add(num)
            
    print(len(pnum)+1)

Solution (Python):
A, B = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
def cnt_pfact(n):
    ans = 1
    _n = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if _n%i==0:
            cnt=0
            while _n%i==0:
                cnt+=1
                _n //= i
            ans += 1
    if _n!=1:
        ans += 1
    return ans
  
print(cnt_pfact(gcd(A, B)))

Solution (Python):
import math

a, b = map(int, input().split())
cnt = 1
i = 2
c, d = a, b

while d > 0:
    c, d = d, c % d

k = int(math.sqrt(c))

while c > 1:
    if c % i == 0:
        cnt += 1
        
        while c % i == 0:
            c //= i

    i += 1

    if k < i:
        cnt += 1
        break

print(cnt)

Solution (Python):
a, b = [int(v) for v in input().split()]

count = 1
div = 3
if a % 2 == 0 and b % 2 == 0:
    count += 1
while a % 2 == 0:
    a //= 2
while b % 2 == 0:
    b //= 2
if a < b:
    a, b = b, a
while b >= div * div:
    if a % div == 0 and b % div == 0:
        count += 1
    while a % div == 0:
        a //= div
    while b % div == 0:
        b //= div
    div += 2
    if a < b:
        a, b = b, a
if b > 1 and a % b == 0:
    count += 1

print(count)

Solution (Python):
a,b=map(int,input().split())
import fractions
gcds=fractions.gcd(a,b)
cnt=0
primelist=[2]

while gcds%2==0:
    gcds=gcds//2
    cnt+=1

n = 10**6
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                
prime.remove(2)

for some in prime:
    if gcds%some==0:
        while gcds%some==0:
            gcds=int(gcds/some)
        primelist.append(some)  

if gcds!=1 and cnt>=1:
    primelist.append("larger")
    primelist.append(1)
    
elif gcds!=1 and cnt==0:
    primelist.append("larger")
    primelist.remove(2)
    primelist.append(1)
elif gcds==1 and cnt>=1:
    primelist.append(1)
elif gcds==1 and cnt==0:
    primelist.remove(2)
    primelist.append(1)

print(len(primelist))

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

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

A_set = prime_factor(A)
B_set = prime_factor(B)

num_set = A_set.intersection(B_set)










print(len(num_set)+1)

Solution (Python):
def factorization(n):
    arr = [[1,1]]
    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 =list(map(int, input().split(" ")))

val = min(A,B)
lim = int(val ** 0.5)


ms = factorization(min(A,B)) 
res = []
maxi = max(A,B)

for v, _ in ms:
    if maxi % v == 0:
        res.append(v)
print(len(res))

Solution (Python):
import math
import sys
a, b = map(int, input().split())
x = min(a, b)
y = max(a, b)

if x == 1:
    print(1)
    sys.exit()


d = []
for i in range(1, int(math.sqrt(x))+1):
    if x % i == 0:
        d.append(i)
        d.append(int(x/i))

zero = 0
for i in range(len(d)):
    if y % d[i] != 0:
        d[i] = 0
        zero += 1

if zero != 0:
    for i in range(zero):
        d.remove(0)

if len(d) == 1:
    print(1)
    sys.exit()

    
ans = 0
for i in range(len(d)):
    flag = 1
    for j in range(2, int(math.sqrt(d[i])) +1):
        if d[i] % j == 0:
            flag = 0
            break
    
    if flag == 1:
        ans += 1

print(ans)

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

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

g = gcd(b, a % b)

div = []
for i in range(1, int(g**0.5)+1):
    if g % i == 0:
        div.append(i)
        if i != g // i:
            div.append(g//i)

def is_prime(x):
    if x == 2: return True
    if not x % 2: return False
    for j in range(3, floor(sqrt(x))+1, 2):
        if not x % j: return False
    else: return True

ans = 0
for d in div:
    ans += is_prime(d)

print(ans)

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

i = 1
j = 1
table_a = []
while i * i <= a:
    if a%i == 0:
        table_a.append(i)
        table_a.append(a//i)
    i += 1
table_a = list(set(table_a))

table_b = []
while j * j <= b:
    if b%j == 0:
        table_b.append(j)
        table_b.append(b//j)
    j += 1
table_b = list(set(table_b))

table = set(table_a) & set(table_b)
nums = list(table)

cnt = 0
for i in range(len(nums)):
    if is_prime(nums[i]):
        cnt += 1
print(cnt+1)

Solution (Python):
import fractions as fr
import math

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)

    divisors.sort()
    return divisors


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

a=fr.gcd(A,B)
U=make_divisors(a)

JJ=0
for i in U:
    if is_prime(i)==True:
        JJ+=1
print(JJ+1)

Solution (Python):
import fractions

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
  
a, b = map(int, input().split())

ans = prime_factorize(fractions.gcd(a, b))
ans = set(ans)
print(len(ans)+1)

Solution (Python):
a,b = map(int, input().split())
import fractions
import collections
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
myset={1}
mygcd=fractions.gcd(a,b)
myset=myset | set(prime_factorize(mygcd))
print(len(myset))

Solution (Python):
import math
a,b=map(int,input().split())
while b!=0:
    a,b=b,a%b
c=a
d=[]
for i in range(2,int(c**0.5)+2):
    while c%i==0:
        c//=i
        d.append(i)
if c!=1:
    d.append(c)
print(len(set(d))+1)

Solution (Python):
import fractions
import collections

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

a, b = map(int, input().split())
g = fractions.gcd(a, b)
c = collections.Counter(fact(g))

print(len(c)+1)

Solution (Python):
from fractions import gcd
from itertools import count, chain, product

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

g = gcd(A, B)

divisors = []
for i in chain([2], range(3, int(g ** 0.5) + 1, 2)):
    firsttime = True
    while g % i == 0:
        g //= i
        if firsttime:
            divisors.append(i)
            firsttime = False
    if g == 1:
        break
if g != 1:
    divisors.append(-1)

print(len(divisors) + 1)

Solution (Python):
import fractions

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

a,b=map(int,input().split())
ab_gcd=fractions.gcd(a,b)
div_list=make_divisors(ab_gcd)
prime_list=[]

for i in div_list:
    flg=True
    for j in prime_list:
        if j == 1:
            continue
        if i % j == 0:
            flg = False
            break
    if flg:
        prime_list.append(i)

print(len(prime_list))

Solution (Python):
import math


def is_prime(n):
    if n == 1 or n == 2: return True
    for k in range(2, int(math.sqrt(n))+1):
        if n % k == 0:
            return False
    return True


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


a, b = map(int, input().split())
a_div = make_divisors(a)
b_div = make_divisors(b)
a_b_div = list(set(a_div).intersection(set(b_div)))
cnt = 0
for num in a_b_div:
    if is_prime(num):
        cnt += 1
print(cnt)

Solution (Python):
import fractions
a,b=map(int,input().split())
c=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])

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

    return arr
if c==1:
  print(1)
else:
  print(len(factorization(c))+1)

Solution (Python):
import math

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

def soinsu(test):
    list_sosu = []
    x = 0
    while x==0:
        for i in range(2,test+1):
            if i > int(math.sqrt(test)):
                list_sosu.append(test)
                x = 1
                break
            elif test % i == 0:
                test = int(test/i)
                if test == 1:
                    x = 1
                list_sosu.append(i)
                break
    return set(list_sosu)

if A == 1 or B == 1:
    print(1)
    
else:
    print(len(soinsu(A)&soinsu(B))+1)

Solution (Python):
import sys
from random import randint

a, b = map(int, sys.stdin.readline().split())

def isPrime(n, k=5): 
	if n < 2: return False
	for p in [2,3,5,7,11,13,17,19,23,29]:
		if n % p == 0: return n == p
	s, d = 0, n-1
	while d % 2 == 0:
		s, d = s+1, d//2
	for i in range(k):
		x = pow(randint(2, n-1), d, n)
		if x == 1 or x == n-1: continue
		for r in range(1, s):
			x = (x * x) % n
			if x == 1: return False
			if x == n-1: break
		else: return False
	return True

x = min(a, b)
def divisors(a, b):
	divs = set()
	i = 1
	while i*i <= x:
		if a%i == 0 and b%i==0:
			if isPrime(i):
				divs.add(i)
		other = a//i 
		if a%other == 0 and b%other==0:
			if isPrime(other):
				divs.add(other)
		i += 1
	return divs

res = divisors(a, b)
print(len(res)+1)

Solution (Python):
N, M  = 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

n = make_divisors(N)
m = make_divisors(M)

res = set(n) & set(m)

res = list(res)

res.sort()


def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

result = 0
for i in range(len(res)):
    if is_prime(res[i]):
        result += 1


print(result+1)

Solution (Python):
import sys

def gcd (x,y):
  if y :
    return gcd(y, x%y)
  else:
    return x
  


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,sys.stdin.readline().split())
ansList=factorization(gcd(A,B))
if ansList[0][0] == 1:
  print(len(ansList))
else:
  print(len(ansList)+1)

Solution (Python):
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  def gcd(a,b):
    if a < b:
      a, b = b, a
    while b > 0:
      a, b = b, a % b
    return a

  
  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
  

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

  max_gcd = gcd(a,b)

  ans = set(prime_factorize(max_gcd))

  print(len(ans)+1)

  
if __name__ == '__main__':
  solve()

Solution (Python):



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

if A < B:
  A, B = B, A

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

def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
ans = factorize(gcd(A, B))
print('{}'.format(len(ans)+1))

Solution (Python):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

MOD = 10**9+7

def main():
    A,B=[int(x) for x in input().split()]

    max_gcd=gcd([A,B])
    P=prime_factor(max_gcd)
    P2=set(P)
    print(len(P2)+1)

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass 

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

main()

Solution (Python):
def prime_factorize(n):
    a = []
    a.append(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 a

A, B = map(int, input().split())
a_prime = set(prime_factorize(A))
b_prime = set(prime_factorize(B))
prime = a_prime & b_prime
print(len(prime))

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 solve():
    import fractions
    A,B = map(int, input().split())
    gcd = fractions.gcd(A,B)
    prime_factor = list(set(prime_factorize(gcd)))
    
    ans = int(len(prime_factor))
    for i in range(int(2**len(prime_factor))):
        i_temp = i
        j = 0
        composite = 1
        count = 0
        while i_temp != 0:
            if i_temp%2 == 0:
                pass
            elif i_temp%2 == 1:
                composite *= prime_factor[j]
                count += 1
            j += 1
            i_temp /= 2
        
        for j in prime_factor:
            if j == composite and count >= 2:
                ans -= 1

    print(ans + 1) 

solve()

Solution (Python):
def prime(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

a, b = map(int,input().split())
x = prime(a)
y = prime(b)
print(len(set(x) & set(y)) + 1)

Solution (Python):
A, B = map(int, input().split())
list = [A, B]
list.sort()

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

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

import collections
c = collections.Counter(prime_factorize(gcd(A, B)))

print(len(c)+1)

Solution (Python):
from fractions import gcd
a,b = map(int, input().split())

count = 2
n=gcd(a,b)

ans = set([1])
while n % 2 == 0:
    ans.add(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        ans.add(f)
        n //= f
    else:
        f += 2
if n != 1:
    ans.add(n)
print(len(ans))