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 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


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 


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


if __name__ == '__main__':
    ta, tb = map(int,input().split())

    
    if ta > tb:
        a = tb
        b = ta
    else:
        a = ta
        b = tb

    a_div_set = set(divisor(a))
    b_div_set = set(divisor(b))
    common_div_set = (a_div_set & b_div_set)

    answer = 0
    for e in common_div_set:
        if e == 1 or is_prime(e):
            answer += 1
    print(answer)

Solution (Python):
import fractions
import sys

input = sys.stdin.readline


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


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

    
    g = fractions.gcd(a, b)
    print(len(set(factorization(g))) + 1)


if __name__ == "__main__":
    main()

Solution (Python):
import fractions

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


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

gcd_ = fractions.gcd(A,B)
if gcd_ == 1:
  print(1)
else:
  print(len(set(trial_division(gcd_)))+1)

Solution (Python):
import fractions as f,subprocess as s;print(len(set(s.Popen(('factor',str(f.gcd(*map(int,input().split())))),stdout=s.PIPE).stdout.read().split())))

Solution (Python):
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x
  
def pf(x):
    s = []
    while x % 2 == 0:
        s.append(2)
        x = x // 2
    i = 3
    while i**2 <= x:
        while x % i == 0:
            s.append(i)
            x = x // i
        i = i + 2
    if x != 1:
        s.append(x)
    return(s)
A, B = list(map(int,input().split()))
x = gcd(A, B)
ans = pf(x)
ans = set(ans)
print(len(ans)+1)

Solution (Python):
import math

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

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

def prime_factorize(n):
    res = []
    tmp = n

    for i in range(2, int(math.sqrt(n))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            res.append([i, cnt])

    if tmp != 1:
        res.append([tmp, 1])

    if len(res) == 0 and n != 1:
        res.append([n, 1])

    return(res)






g = gcd(A, B)
div = prime_factorize(g)
ans = len(div) + 1
print(ans)

Solution (Python):
import fractions as f,subprocess as s;print(len(set(s.Popen(('factor',str(f.gcd(*map(int,input().split())))),stdout=s.PIPE).communicate()[0].split())))

Solution (Python):
import fractions as f,subprocess as s;print(len(set(s.Popen(('factor',str(f.gcd(*map(int,input().split())))),stdout=s.PIPE).communicate()[0].split()[1:]))+1)

Solution (Python):
import fractions as f,subprocess as s;print(len(set(map(int,s.Popen(('factor',str(f.gcd(*map(int,input().split())))),stdout=s.PIPE).communicate()[0].split()[1:])))+1)

Solution (Python):
from fractions import*
from subprocess import*
print(len(set(map(int,Popen(('factor',str(gcd(*map(int,input().split())))),stdout=PIPE).communicate()[0].split()[1:])))+1)

Solution (Python):

from fractions import gcd
import itertools
import sys
input = sys.stdin.readline



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



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 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 coprime(a, b):
    return gcd(a, b) == 1


def main():
    A, B = map(int, input().split())
    gcdab = gcd(A, B)
    cd = divisor(gcdab)
    
    
    
    
    
    
    
    

    ans = 0

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

    print(ans)

    
    
    
    
    
    
    

    
    
    
    

    
    

    
    


if __name__ == '__main__':
    main()

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


def factorize(n):
    res = set()

    diviser = 2
    exponent = 0
    while n % diviser == 0:
        exponent += 1
        n //= diviser
    if exponent > 0:
        res.add((diviser, exponent))
    
    

    to = int(pow(n, 0.5))
    for diviser in range(3, to + 1, 2):
        exponent = 0
        while n % diviser == 0:
            exponent += 1
            n //= diviser
        if exponent > 0:
            res.add((diviser, exponent))

    if n > 1:
        res.add((n, 1))
        

    return res


def main():
    a, b = map(int, input().split())
    g = gcd(a, b)
    e = factorize(g)

    ans = len(e) + 1
    
    
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

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

def prime_factorize(n):
    res = []
    tmp = n

    for i in range(2, int(math.sqrt(n))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            res.append([i, cnt])

    if tmp != 1:
        res.append([tmp, 1])

    if len(res) == 0 and n != 1:
        res.append([n, 1])

    return(res)

c = gcd(A, B)

div = prime_factorize(c)

ans = len(div) + 1
print(ans)

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 = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp%i == 0:
            cnt = 0
            while tmp%i == 0:
                cnt += 1
                tmp /= i
            arr.append([i,cnt])
    if tmp != 1:
        arr.append([tmp,1])
    return arr

print(len(factorize(gcd(a,b)))+1)


"""        
cf = []
for i in range(2,min(a,b)+1):
    if a % i == 0 and b % i == 0:
        cf.append(i)

print(cf)


dest = int(math.sqrt(cf))
cf_list = list(range(2, cf+1))
prime_list = []

for i in range(len(cf)):
    num_min = min(cf_list[i])
    if num_min >= dest:
        prime_list.extend(cf_list[i])
        break
    prime_list.append(num_min)

    j = 0

    while True:
        if i>= len(cf_list):
            break
        elif cf_list[i] % num_min == 0:
            cf_list.pop(i)
        j += 1

print(prime_list)
"""

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













def Soinsu(N):
    soinsu = set([1]) 
    if N > 1:
        
        div2_flg = 1
        while div2_flg:
            if N % 2 == 0:
                soinsu.add(2)
                N = N/2
            else:
                div2_flg = 0

        for i in range(3,int(N)+1,2):

        
            div_flg = 1
            while div_flg:

                if N % i == 0:
                    soinsu.add(i)
                    N = N/i
                else:
                    div_flg = 0
            
            if i**2 > N:
                break
        
        soinsu.add(N)
        
    return(soinsu)
            
soi_A = Soinsu(A)
soi_B = Soinsu(B)


print(len(soi_A & soi_B))

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


while b:
    a, b = b, a % b



if a == 1 :
    print(1)
else :
    def factorization(a):
        arr = []
        temp = a
        for i in range(2, int(-(-a**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([a, 1])

        return arr

    print(int(len(factorization(a)) + 1))

Solution (Python):
import fractions

def devided(x):
    y = x
    devisors = 1
    for i in range(2, int((y**0.5)) + 1):
        if (x % i) == 0:
            devisors += 1
            while (x % i == 0):
                x //=  i
        else:
            continue
    if x > 1:
            devisors += 1
    return devisors

get = input().split()
A = int(get[0])
B = int(get[1])

C = fractions.gcd(A,B)

print(devided(C))

Solution (Python):
def trial_division(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

from fractions import gcd

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

g = gcd(A,B)

L = trial_division(g)

D = {}

for i in L :
    if i not in D :
        D[i] = 1

print(len(D)+1)

Solution (Python):

from math import sqrt

def get_gcd(a, b):
    if b == 0:
        return a
    else:
        return get_gcd(b, 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

N, K = map(int, input().split())
gcd = get_gcd(N, K)
print(len(factorization(gcd)) + 1) if gcd > 1 else print(1)

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

Aprime = set(prime_factorize(A))
Bprime = set(prime_factorize(B))
ABintr = Aprime & Bprime


print(len(ABintr))

Solution (Python):
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

from collections import defaultdict
def factorize(n: int) -> dict:
    f = defaultdict(int)
    tmp_n = n
    p = 2
    while tmp_n > 1 and p * p < n:
        while tmp_n % p == 0:
            f[p] += 1
            tmp_n = tmp_n // p
        p += 1 if p == 2 else 2

    if tmp_n != 1:
        f[tmp_n] += 1
    return f

a, b = map(int, input().split())
factors = factorize(GCD(a, b))

ans = len(factors) + 1

print(ans)

Solution (Python):

import fractions

def main():
    A,B = map(int,input().split())
    C = fractions.gcd(A,B)
    Cn = prime_factorize(C)
    Cn = list(set(Cn))
    print(len(Cn)+1)

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

if __name__ == '__main__':
    main()

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

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

def main():
    A,B=map(int, input().split())
    ans = factorization(gcd(A,B))
    if ans[0][0] == 1:
        print(1)
    else:
        print(len(ans)+1)

if __name__ == '__main__':
    main()

Solution (Python):
import fractions

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 = list(map(int,input().split(" ")))
g = fractions.gcd(a,b)
if g == 1:
  print(1)
else:
  print(len(factorization(g)) + 1 )

Solution (Python):

import fractions

import collections

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

if __name__ == "__main__":
    
    a, b = map(int, input().split())
    
    g = fractions.gcd(a, b)
    
    

    c = collections.Counter(prime_factorial(g))
    print(len(list(c.keys())) + 1)

Solution (Python):
from math import sqrt, ceil

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

c_a = set()
c_b = set()

for i in range(1, ceil(sqrt(a))+1):
  if a % i == 0:
    c_a.add(i)
    if i > 1:
        while a % i == 0:
            a = a // i
if a != 1:
    c_a.add(a)

for j in range(1, ceil(sqrt(b))+1):
  if b % j == 0:
    c_b.add(j)
    if j > 1:
        while b % j == 0:
            b = b // j
if b != 1:
    c_b.add(b)

ans = c_a.intersection(c_b)

print(len(ans))

Solution (Python):
from collections import deque
A, B = [int(x) for x in input().split()]

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

t = gcd(A, B)
l = deque([1])
sqrt_t = int(t ** 0.5) + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
      
l.append(t)
print(len(set(l)))

Solution (Python):
a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
n = gcd(a, b)
ndiv = n
if n == 1:
    print(1)
else:
    i = 1
    primecount = 0
    divisor = False
    while True:
        i += 1
        while ndiv%i == 0:
            ndiv = ndiv//i
            divisor = True
        if divisor:
            primecount += 1
            divisor = False
            if ndiv == 1:
                break
        if ndiv != 1 and i*i > n:
            primecount += 1
            break
    print(primecount+1)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)

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

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

g = gcd(A, B)
count = 0
for i in range(2, 10**6+3):
    if g%i == 0:
        count += 1
    while g%i == 0:
        g //= i
if g != 1:
    count += 1

print(count+1)

Solution (Python):
import fractions
import math
from collections import deque

def prime(x):
  px = []
  limit = int(math.sqrt(x))
  for i in range(2, limit+1):
    flag = False
    while x % i == 0:
      flag = True
      x = x // i
    if flag:
      px.append(i)
  if x != 1:
    px.append(x)
  return px

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

pa = prime(a)
pb = prime(b)

cnt = 1
j = 0

for i in range(len(pa)):
  while j < len(pb) and pb[j] < pa[i]:
    j += 1
  if j == len(pb):
    break
  elif pb[j] == pa[i]:
    cnt += 1
  
print (cnt)

Solution (Python):
import math
 
 
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
  
 
a, b = map(int, input().split())
 
gcd = gcd(a, b)
 
res = set([1])
while gcd % 2 == 0: 
        res.add(2)
        gcd = gcd // 2
 
for i in range(3,int(math.sqrt(gcd))+1,2): 
    while gcd % i == 0: 
        res.add(i)
        gcd = gcd // i 
            
if gcd > 2: 
    res.add(gcd)
 
print(len(res))

Solution (Python):

import fractions


def solve(arg: str) -> str:
    a, b = map(int, arg.split())
    div = [1]

    g = fractions.gcd(a, b)
    n = 2
    while n*n <= g:
        if g % n == 0:
            div.append(n)
            while g % n == 0:
                g = int(g/n)
        n += 1
    if g != 1:
        div.append(g)

    return str(len(div))


if __name__ == "__main__":
    print(solve(input()))

Solution (Python):
import collections

def gcd(a,b):
    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())
N=gcd(A,B)
c = collections.Counter(prime_factorize(N))
print(len(list(c.keys()))+1)

Solution (Python):





import math


def sosuhante(n):
    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())
    m=4
    k=1
    count=0

    if a>b:
        a,b=b,a
    sosu={1}

    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3

    c=math.sqrt(a)+1
 
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1

    sosu.add(a)


    for i in sosu:
        if b%i==0:
            count+=1
    print(count)



if __name__ == "__main__":
    main()

Solution (Python):
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd ** 0.5) + 1):
        if gcd % i == 0:
            cnt += 1
            while True:
                if gcd % i == 0:
                    gcd //= i
                else:
                    break
    if gcd != 1:
        cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

Solution (Python):
import fractions
import math
def x(n):
    a=[1]
    for i in range(2,int(math.sqrt(n))+1):
        while n%i==0:
            n//=i
            a.append(i)
    a.append(n)
    return a
A,B = map(int,input().split())
n=fractions.gcd(A,B)
print(len(set(x(n))))

Solution (Python):





import math


def sosuhante(n):
    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())
    m=4
    k=1
    count=0

    if a>b:
        a,b=b,a
    sosu={1}

    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3

    c=math.sqrt(a)+1
 
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1

    if a!=1:
        sosu.add(a)


    for i in sosu:
        if b%i==0:
            count+=1
    print(count)



if __name__ == "__main__":
    main()

Solution (Python):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

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()
print(len(set(prime_factorize(a)) & set(prime_factorize(b)))+1)

Solution (Python):
A, B = map(int, input().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

import fractions
x = fractions.gcd(A, B)
ans = prime_factorize(x)
print(len(set(ans))+1)

Solution (Python):
import fractions
import math

def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a


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

ans = set(trial_division(max_n))
print(len(ans))

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

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

Solution (Python):

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

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,int(math.sqrt(g))+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False

    first = True

if g != 1:
    cnt += 1

print(cnt+1)

Solution (Python):





import math
import fractions

def sosuhante(n):
    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())
    m=4
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()

    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3

    c=math.sqrt(a)+1
 
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1

    if sosu==set() and a!=1:
        sosu.add(a)
    if sosuhante(a) and a!=1:
        sosu.add(a)


    for i in sosu:
        if b%i==0:
            count+=1
    print(count)



if __name__ == "__main__":
    main()

Solution (Python):





import math
import fractions

def sosuhante(n):
    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())
    m=4
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()

    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3

    c=math.sqrt(a)+1
 
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1

    if sosu==set() and a!=1:
        sosu.add(a)
    if sosuhante(a) and a!=1:
        sosu.add(a)

    m=4
    k=1

    count=1
    sosub=set()

    if b%2==0:
        sosub.add(2)
        while b%2==0:
            b//=2
    if b%3==0:
        sosub.add(3)
        while b%3==0:
            b//=3

    c=math.sqrt(b)+1
 
    while m<=c and m!=1:
        if b%m==0:
            sosub.add(m)
            while b%m==0:
                b//=m

        m+=1

    if sosub==set() and b!=1:
        sosub.add(b)
    if sosuhante(b) and b!=1:
        sosub.add(b)

    for i in sosu:
        if i in sosub:
            count+=1
    print(count)



if __name__ == "__main__":
    main()

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

print(len(set(factorize(a))&set(factorize(b)))+1)

Solution (Python):





import math
import fractions

def sosuhante(n):
    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())
    m=4
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    a = fractions.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3

    c=math.sqrt(a)+1
 
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1

    if sosu==set() and a!=1:
        sosu.add(a)
    if sosuhante(a) and a!=1:
        sosu.add(a)

    count+=len(sosu)
    print(count)



if __name__ == "__main__":
    main()

Solution (Python):
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

def get_divisor(n: int) -> list:
    divisor = []
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            divisor.append(i)
            if i != n // i:
                divisor.append(n // i)
    divisor.sort()
    return divisor

a, b = map(int, input().split())
divisor =  get_divisor(GCD(a, b))

ans = 1
used = [0] * len(divisor)
used[0] = 1
for i in range(1, len(divisor)):
    if used[i] == 0:
        ans += 1
        for j in range(i+1, len(divisor)):
            if used[j] == 0 and divisor[j] % divisor[i] == 0:
                used[j] = 1

print(ans)

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


def prime_decomposition(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


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

    P = set(prime_decomposition(gcd(A, B)))
    
    print(len(P) + 1)
    

 
if __name__ == '__main__':
    main()

Solution (Python):
import math

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

while B > 0:
    A, B = B, A % B
N = A

ans = 1
i = 2
while i * i <= N:
    if N % i == 0:
        while N % i == 0:
            N //= i
        ans += 1
    i += 1
if N > 1:
    ans += 1
print(ans)

Solution (Python):
import math

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

while B > 0:
    A, B = B, A % B
N = A

ans = 1
for i in [2] + list(range(3, int(math.sqrt(N)) + 2, 2)):
    if N % i == 0:
        while N % i == 0:
            N //= i
        ans += 1
if N > 1:
    ans += 1
print(ans)

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
    
A, B = map(int, input().split())
A_list = set(prime_factorize(A))
B_list = set(prime_factorize(B))

print(len(A_list & B_list) + 1)

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

la=fac(b[0])
lb=fac(b[1])


print(len(set(la) & set(lb))+1)

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

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = 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 a

ans = set(prime_factorize(n))
print(len(ans)+1)

Solution (Python):
def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def prime(x):
    global  ans
    m = x ** (0.5)
    for i in range(2,int(m+1)):
        if x % i == 0 :
            while True:
                if x % i != 0 :
                    break
                else:
                    x = (x//i)
            ans +=1
    if x != 1 :
        ans += 1
    return ans
A,B = map(int,input().split())
t = gcd(A,B)
ans = 1
print(prime(t))

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

def pf(n):
    a, odd = {1}, 3
    while n%2==0:
        a.add(2)
        n //= 2
    while odd**2<=n:
        if n%odd==0:
            a.add(odd)
            n //= odd
        else:
            odd += 2
    a.add(n)
    return a

def main():
    a, b = map(int, input().split())
    print(len(pf(gcd(a, b))))

if __name__ == "__main__":
    main()

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

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 isprime(n):
    sup = int(n**0.5)
    for i in range(2, sup+1):
        if n%i==0:
            return False
    return True

A, B = map(int, input().split())
g = gcd(A, B)
divs = make_divisors(g)
ans = 0
for d in divs:
    ans += 1 if isprime(d) else 0
print(ans)

Solution (Python):
A, B = map(int, input().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

ap = prime_factorize(A)
bp = prime_factorize(B)

print(len(set(ap) & set(bp)) + 1)

Solution (Python):
def gcd(x, y):
    m = max(x, y)
    n = min(x, y)
    z = y
    while m % n == 0:
        z = x % y
        x = y
        y = z
    return z

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

x, y = map(int, input().split())

z = prime_factorize(x)
w = prime_factorize(y)

zz = set(z) & set(w)
print(len(zz)+1)

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

import math

if A < B:
    A, B = B, A
    
while A % B != 0:
    A, B = B, A%B
    
ans = 1

for i in range(2, int(math.sqrt(B))+1):
    if B % i == 0:
        ans += 1
        
        while B % i == 0:
            B //= i
            
if B > 1:
    ans += 1
    
print(ans)