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

def yaku(n):
  l=[]
  m=n
  for i in range(1,int((n)**(1/2))+1):
    if m%i==0:
      l.append(i)
      if m//i!=i:
        l.append(m//i)
  return l

def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a

def prime(n):
  for i in range(2,int((n)**(1/2))+1):
    if n%i==0:
      return False
  return True

num=gcd(a,b)

l0=yaku(num)

num1=max(l0)

cd=yaku(num1)

pr=[]

for i in cd:
  if i==1:
    pr.append(i)
  else:
    if prime(i):
      pr.append(i)

print(len(pr))

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

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

af = set(factorize(a))
bf = set(factorize(b))

count = 0
print(len(af&bf)+1)

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

def gcd(x,y):
  if y > x:
    x, y = y, x
  while x % y != 0:
    x, y = y, x % y
  return 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



if __name__ == "__main__":
  gcd = gcd(A, B)
  c = collections.Counter(prime_factorize(gcd))
  ans = len(c.keys()) + 1
  print(ans)

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

A, B = map(int, input().split())
prime1 = get_prime(A)
prime2 = get_prime(B)
ans_prime = set(prime1) & set(prime2)
print(len(ans_prime) + 1)

Solution (Python):
A,B = map(int, input().split())
while B != 0: A, B = B, A % B 

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

c = 2
if A%c == 0:
    ans += 1
while A%c == 0:
    A //= c

c = 3
while c**2 <= A:
    if A == 1:
        break
    if A%c == 0:
        ans += 1
    while A%c == 0:
        A //= c
    c += 2

if A != 1: 
    ans += 1

print(ans+1)

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


a,b=(int(x) for x in input().split())

def factorize(n):
    b = 2
    
    fct = [1]
    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)))))

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


a,b=(int(x) for x in input().split())

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


if len(set(factorize(a))&set(factorize(b)))==1:
    print(1)
else:
    print(len((set(factorize(a))&set(factorize(b)))))

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

X,Y= [int(i) for i in input().split()]
x=min(X,Y)
y=max(X,Y)

a=y%x
if a !=0:
        while a > 1:
                y=x
                x=a
                a=y%x
                
print(len(set(factorize(x))) + 1 if a==0 else 1)

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

a,b=[int(i) for i in input().split()]
val = gcd(a,b)

ct=1

for i in range(2,int(val**0.5)+2):
    if(val%i==0):
        ct+=1
        while(val%i==0):
            val//=i
if(val!=1):
    ct+=1
print(ct)

Solution (Python):
import fractions
a,b = map(int,input().split())
"""素因数分解"""
def factrize(n):
	b = 2
	fct = []
	while b*b <= n:
		while n % b == 0:
			n //= b
			
			
			if not b in fct:
				fct.append(b)
			
			
		b = b+1
	if n > 1:
		fct.append(n)
	return fct 

gc = fractions.gcd(a,b)

ans = factrize(gc)
print(len(ans)+1)

Solution (Python):
from sys import stdin


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, stdin.readline().rstrip().split())

Aprime = prime_factorize(A)
Bprime = prime_factorize(B)

Aset = set(Aprime)
Bset = set(Bprime)

cup = Aset & Bset






print(1 + len(cup))

Solution (Python):
def yakusu(x):
    ans=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            ans.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
        ans.append(x)
    return ans
def main():
    a,b = map(int,input().split())	
    ans=0
    y1=yakusu(a)
    for i in y1:
        if b%i==0:
            ans+=1
    print(ans)

main()

Solution (Python):
def yakusu(x):
    ans=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            ans.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      ans.append(x)
    return ans
def main():
    a,b = map(int,input().split())	
    ans=0
    y1=yakusu(a)
    for i in y1:
        if b%i==0:
            ans+=1
    print(ans)
 
main()

Solution (Python):
def yakusu(x):
    ans=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            ans.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      ans.append(x)
    return ans
def main():
    a,b = map(int,input().split())	
    ans=0
    y1=yakusu(a)
    for i in y1:
        if b%i==0:
            ans+=1
    print(ans)

main()

Solution (Python):
import fractions
import numpy as np

A, B = map(int, open(0).read().split())
G = fractions.gcd(A, B)
upper_limit = int(np.sqrt(G))
ans = 1
for i in range(upper_limit):
    if G % (i + 2) == 0:
        ans += 1
        
        while G % (i + 2) == 0:
            G /= (i + 2)
            
if G != 1:
    ans += 1
print(ans)

Solution (Python):
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(max(A,B)))+1
g = G
ans = 1

for i in range(2, N+3):
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g = g/i
            
if g != 1:
    ans += 1

print(ans)

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

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

n = gcd(a,b)
m = n
ans = 1

if m%2==0:
    ans += 1
    while m%2==0:
        m //= 2
f = 3

while f*f <= n:
    if m%f==0:
        ans += 1
        while m%f==0:
            m //= f
    f+=2

if m!=1:
    ans += 1

print(ans)

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

cd = []

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


for i in range(1,int(A**0.5)+1):
    if A % i == 0:
        if B % i == 0:
            cd.append(i)
        if B % (A / i) == 0:
            cd.append(int(A / i))

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

print(ans)

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 math

def trial_division(target):
    dest = int(math.sqrt(target)) + 1

    for i in range(2, dest):
        if target % i == 0:
            return 0
    return 1

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

a_set = set(make_divisors(a))
b_set = set(make_divisors(b))

ab_set = a_set & b_set

c = 0
for ab in list(ab_set):
    c += trial_division(ab)

print(c)

Solution (Python):
A,B=list(map(int,input().split(" ")))
from collections import defaultdict
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=prime_factorize(A)
b=prime_factorize(B)
count1=defaultdict(lambda:0)
count2=defaultdict(lambda:0)
for i in range(len(a)):
    count1[a[i]]+=1
for i in range(len(b)):
    count2[b[i]]+=1

c=count1.keys()
d=count2.keys()
num=0
for i in c:
    if i in d:
        num+=1
print(num+1)

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

    if num != 1:
        ans_list.append(num)

    if ans_list == []:
        ans_list.append(temp)
    ans_list.append(1)
    return ans_list

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

ans = set(prime_bunkai(A)) & set(prime_bunkai(B))
print(len(ans))

Solution (Python):
from math import sqrt, ceil

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

def gcd(a, b):
  x, y = (a, b) if a > b else (b, a)
  while y > 0:
    x, y = y, x % y
  return x

d = gcd(a, b)
ans = 1
for i in range(2, ceil(sqrt(d))+1):
  if d % i == 0:
    ans += 1
    while(d % i == 0):
      d = d / i
if d != 1:
    ans += 1
print(ans)

Solution (Python):
import numpy as np
 

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])
 
    
    arr.append([1, 1])
 
    return arr


a, b = map(int, input().split())
 
x = np.array(factorization(a))
y = np.array(factorization(b))
 
num = set(x[:, 0]) & set(y[:, 0])
 
print(len(num))

Solution (Python):






















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


def div(n):
    """give divisors"""
    divisors = [1]
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            divisors.append(i)
            n /= i
    if n != 1:
        divisors.append(int(n))
    return set(divisors)


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

c = div(euc(a, b))

print(len(c))

Solution (Python):
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(2, int(sqrt_a) ):  
  if (a % (i) == 0):
    list_a.append( i )
    while( a % (i) == 0 ):
      a = a//(i)
if a > 1:
  list_a.append(a)
      
for i in range(2, int(sqrt_b) ):  
  if (b % (i) == 0):
    list_b.append( i )
    while( b % (i ) == 0 ):
      b = b//(i)
if b > 1:
  list_b.append(b)




set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b
  
print(len(set_ab) + 1)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

def eratosthenes(upperBound):
    """エラトステネスの篩アルゴリズムによって、upperBound以下の素数すべてからなるリストを計算する。

    Args:
        upperBound(int): 計算したい素数リストに含まれる素数の上限値。
    Returns:
        list[int]: 計算された素数リスト。
    
    Examples:
    >>> eratosthenes(10)
    [2, 3, 5, 7]
    >>> eratosthenes(11)
    [2, 3, 5, 7, 11]
    """
    primeNumbers = []
    isPrime = [True for _ in range(upperBound + 1)]
    isPrime[0] = isPrime[1] = False
    divider = 0
    while divider <= math.sqrt(upperBound):
        if isPrime[divider]:
            
            multiple = 2* divider
            while multiple <= upperBound:
                isPrime[multiple] = False
                multiple += divider
        divider += 1
    return [i for i in range(upperBound + 1) if isPrime[i]]

primeNumberList = eratosthenes(1000010)

def factorize(number):
    """与えられた整数を素因数分解する。素因数とその指数を辞書として返却する。

    Args:
        number(int) 
    Returns:
        dict[int,int] 素因数->指数の辞書。
    >>> factorize(6)
    {2: 1, 3: 1}
    >>> factorize(20)
    {2: 2, 5: 1}
    """
    exponents = {}
    for primeNumber in primeNumberList:
        while number%primeNumber == 0:
            number /= primeNumber
            if primeNumber in exponents:
                exponents[primeNumber] += 1
            else:
                exponents[primeNumber] = 1
    if number != 1:
        exponents[number] = 1
    return exponents

A,B = map(int,input().split())
gcd = fractions.gcd(A,B)
factorizedGcd = factorize(gcd)
print(len(factorizedGcd.keys()) + 1)

Solution (Python):
from fractions import gcd

def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    ans = 1 if g % 2 else 2
    while g % 2 == 0:
        g //= 2
    for i in range(3, int(g**0.5) + 1, 2):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g //= i
    return str(ans + 1) if g > 1 else str(ans)

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

Solution (Python):
from math import sqrt
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
    
A, B = map(int, input().split())

g = gcd(A, B)
n = int(sqrt(g))+1
ans = 1
for p in range(2,n+1):
    if g%p==0:
        ans += 1
        while g%p==0:
            g = g//p
if g!=1:
    ans += 1

print(ans)

Solution (Python):
import numpy as np
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 gcd(a, b):
    while b:
        a, b = b, a % b
    return a


a,b = map(int,input().split())
gcd = gcd(a ,b)
print(len(np.unique(prime_decomposition(gcd)))+1)

Solution (Python):
from fractions import gcd


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    ans = 1 if g % 2 else 2
    while g % 2 == 0:
        g //= 2
    for i in range(3, int(g**0.5) + 1, 2):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g //= i
    return str(ans + 1) if g > 1 else str(ans)


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

Solution (Python):
from fractions import gcd


def get_primes(n):
    ans = 1 if n % 2 else 2
    while n % 2 == 0:
        n //= 2
    for i in range(3, int(n**0.5) + 1, 2):
        if n % i == 0:
            ans += 1
        while n % i == 0:
            n //= i
    return ans + 1 if n > 1 else ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(get_primes(g))


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

Solution (Python):
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = 1
    m = int(n**0.5) + 1
    flags = np.zeros(m + 1, dtype=bool)
    for i in range(2, m + 1):
        if flags[i]:
            continue
        if n % i == 0:
            ans += 1
        while n % i == 0:
            n //= i
        flags[i:m + 1:i] = 1
    return ans + 1 if n > 1 else ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(get_primes(g))


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

Solution (Python):
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = 1
    m = int(n**0.5) + 1
    flags = np.zeros(m + 1, dtype=bool)
    for i in range(2, m + 1):
        if flags[i]:
            continue
        if n % i == 0:
            ans += 1
        while n % i == 0:
            n //= i
        flags[i:m + 1:i] = 1
    if n > 1:
        ans += 1
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(get_primes(g))


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

Solution (Python):
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(2, int(sqrt_a)):
    if (a % (i) == 0):
        list_a.append(i)
        while(a % (i) == 0):
            a = a//(i)
if a != 1:
    list_a.append(a)

for i in range(2, int(sqrt_b)):
    if (b % (i) == 0):
        list_b.append(i)
        while(b % (i) == 0):
            b = b//(i)
if b != 1:
    list_b.append(b)




set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b

print(len(set_ab) + 1)

Solution (Python):
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = []
    m = int(n**0.5) + 1
    flags = np.zeros(m + 1, dtype=bool)
    for i in range(2, m + 1):
        if flags[i]:
            continue
        while n % i == 0:
            n //= i
        ans.append(i)
        flags[i:m + 1:i] = 1
    if n > 1 and all(map(lambda x: n % x, ans)):
        ans.append(n)
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


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

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

def factorizaion(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr

x=factorizaion(a)
y=factorizaion(b)
print(len(set(x)&set(y))+1)

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

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

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
  
tmp = set(prime_decomposition(gcd(a,b)))

print(len(tmp)+1)

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_set = set(prime_factorize(a))
b_set = set(prime_factorize(b))
cd = list(a_set & b_set)
print(len(cd)+1)

Solution (Python):
a,b = map(int,input().split())
def gcd(x,y):
    if x < y:
        x,y = y,x
    while x%y != 0:
        a = x%y
        x = y
        y = a
    return y
N = gcd(a,b)
import math
n = math.floor(math.sqrt(N))
ans = 1
for i in range(2,n+1):
    if N%i == 0:
        ans += 1
        while N%i == 0:
            N /= i
if N != 1:
    ans += 1
print(ans)

Solution (Python):

def prime_factorize(x0):
    tmp_l = [1]
    if x0 == 1:
        return tmp_l
    if x0%2 == 0:
        tmp_l.append(2)
        while x0 % 2 == 0:
            x0 //=2
    if x0 > 2:
        i = 3
        while 1:
            if i > pow(x0,1/2):
                if x0 == 1:
                    break
                tmp_l.append(x0)
                break
            if x0 % i == 0:
                tmp_l.append(i)
                while x0 % i == 0:
                    x0 //= i   
            i+=2
    return tmp_l


def gcd(x0, y0):
    if x0<y0:
        tmp0 = x0
        x0 = y0
        y0 = tmp0
    if y0 == 0:
        return x0
    else:
        return gcd(y0, x0 % y0)
        
a,b=map(int,input().split())

g = gcd(a,b)
print(len(prime_factorize(g)))

Solution (Python):
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 trial_division(target):
    if target == 1: return False
    dest = int(math.sqrt(target)) + 1
    
    for i in range(2,dest):
        
        if target % i == 0:
            return False

    return True

A_div = set(make_divisors(A))
B_div = set(make_divisors(B))
AB_div = A_div & B_div

count=1

for i in AB_div:
    
    
    if(trial_division(i)):
        count+=1
print(count)

Solution (Python):
a,b=map(int,input().split())
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def prime_factorize(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
d=prime_factorize(gcd(a,b))
e = len(set(d))
print(e+1)

Solution (Python):


MOD = 10 ** 9 + 7

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


def trial_division(n):
    ret = []
    for p in range(2, int(n**0.5) + 1):
        c = 0
        while n % p == 0:
            n //= p
            c += 1
        if c != 0:
            
            ret.append(p)

    if n > 1:
        
        ret.append(n)

    return set(ret)


pa = trial_division(a)
pb = trial_division(b)
p = pa & pb

ans = len(p) + 1

print(ans)

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

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

G = gcd(A, B)

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

Solution (Python):
import fractions

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

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

G = fractions.gcd(A,B)

F = prime_factorize(G)

print(len(F) + 1)

Solution (Python):
def main():
  import fractions
  import math

  a,b = map(int,input().split())
  g = fractions.gcd(a,b)
  
  d = [1]
  num = 2

  while num**2 <= g:
    
    if g%num == 0:
      d.append(num)
    while g%num == 0 and g>1:
      g = g//num
      
    num += 1
  
  print(len(d) + (g > 1))

if __name__ == "__main__":
  main()

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

Solution (Python):
from fractions import gcd

if __name__ == '__main__':
    n = gcd(*map(int, input().split()))
    a = i = 1
    while i * i < n:
        i += 1
        a += n % i < 1
        while n % i < 1:
            n /= i
    print(a + (n > 1))

Solution (Python):
import math
a, b = map(int,input().split())
c = int(math.sqrt(min(a,b)) +1)
e = max(a,b)
d = min(a,b) 
def pn(x,y):
    isprime = [1 for _ in range(x+1)]
    primes = []
    y = y
    for i in range(2,x+1):
        if isprime[i]:
            s = 2*i
            primes.append(i)
            while s <= x:
                isprime[s] = 0
                s += i
            while y%i==0:
                y = y//i
    if y!=1:
        primes.append(y)
    return primes
    
def pf(x,y,primes):
    pfs = []
    for i in primes:
        fx = x%i
        fy = y%i
        if fx==0 and fy==0:
            pfs.append(i)
            
    return pfs
primes = pn(c,d)
print(len(pf(a,b,primes))+1)

Solution (Python):

from fractions import gcd


def primefact(x0):
    tmp_l = [1]
    if x0 == 1:
        return tmp_l
    i = 2
    while 1:
        if i > pow(x0,1/2):
            if x0 == 1:
                break
            tmp_l.append(x0)
            break
        if x0 % i == 0:
            tmp_l.append(i)
            while x0 % i == 0:
                x0 //= i   
        i+=1
    return tmp_l


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

g = gcd(a,b)
print(len(primefact(g)))

Solution (Python):

def primefact(x0):
    tmp_l = [1]
    if x0 == 1:
        return tmp_l
    i = 2
    while 1:
        if i > pow(x0,1/2):
            if x0 == 1:
                break
            tmp_l.append(x0)
            break
        if x0 % i == 0:
            tmp_l.append(i)
            while x0 % i == 0:
                x0 //= i   
        i+=1
    return tmp_l


def gcd(x0, y0):
    if x0<y0:
        tmp0 = x0
        x0 = y0
        y0 = tmp0
    if y0 == 0:
        return x0
    else:
        return gcd(y0, x0 % y0)
        
a,b=map(int,input().split())

g = gcd(a,b)
print(len(primefact(g)))

Solution (Python):
def primeFac(n):
	res = {1}
	for i in range(2, int(n**0.5) + 1):
		while n % i == 0:
			n //= i
			res.add(i)
		if n <= 1:
			break
	if n > 1:
		res.add(n)
	return res

a, b = map(int, input().split())
res = primeFac(a) & primeFac(b)
print(len(res))

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

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

def factorize(n):
    res = []
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
            continue
        res.append([i, n])
        while n % i == 0:
            n //= i
            res[-1][1] += 1
        i += 1
    if n != 1:
        res.append([n,1])
    return res

g = gcd(A, B)
f = factorize(g)
ans = len(f) + 1
print(ans)

Solution (Python):
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m
a, b = map(int, input().split())
g = gcd(a, b)

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

Solution (Python):

import sys
sys.setrecursionlimit(1000000)

import math

def gcd(i, j):
    """
    2値 i, j の最大公約数を求める。
    """

    if j == 0:
        return i
    else:
        return gcd(j, i % j)

def factorize(n):
    """
    素因数分解した個数を返す
    """
    count = 1
    rep = math.ceil(math.sqrt(n))
    for i in range(2, rep + 1):
        if n % i != 0:
            continue
        else:
            count += 1
            while n % i == 0:
                n /= i
        if n == 1:
            return count
    if n != 1:
        count += 1
    return count

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

    
    x = gcd(a, b)

    
    count = factorize(x)

    
    print(count)

main()

Solution (Python):
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}
 
a, b = map(int,input().split())
print(len(f(a) & f(b) | {1}))

Solution (Python):

from fractions import *

def next_int():
    return int(input())

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

a, b = next_ints()
n = gcd(a, b)
ans = 1
i = 2
while i*i <= n:
    if n%i == 0:
        ans += 1
        while n%i == 0:
            n //= i
    i += 1
if n != 1:
    ans += 1
print(ans)

Solution (Python):
A,B=map(int,input().split())
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
def gcd(a,b):
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)
c=gcd(A,B)

sqrtc=int(c**(1/2))
vc=c
ans=1
for i in range(2,sqrtc+1):
    if vc%i==0:
        ans+=1
        vc/=i
        while vc%i==0:
            vc/=i
if vc!=1:
    ans+=1
print(ans)

Solution (Python):
import math
import fractions
from collections import defaultdict
def trial_division(n):
    
    factor = defaultdict(int)
    factor[1] += 1
    
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor[num] += 1
    
    factor[n] += 1
    return factor

A,B = [int(x) for x in input().split()]
divisions = trial_division(fractions.gcd(A,B))
print(len(divisions))

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

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

Solution (Python):
from fractions import gcd
from math import sqrt
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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


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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
def factorization(n):
    res = set()
    tmp = n
    for i in range(2, int(n ** 0.5) // 1):
        if tmp % i == 0:
            while tmp % i == 0:
                tmp //= i
            res.add(i)
    res.add(tmp)
    return res

a, b = map(int,input().split())
ans = factorization(a) & factorization(b) | {1}
print(len(ans))

Solution (Python):

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


import math

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
A1 = prime_factors(A)
B1 = prime_factors(B)        
C = set(A1) & set(B1)

print(len(C)+1)

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

a, b = map(int,input().split())
ans = factorization(a) & factorization(b) | {1}
print(len(ans))