AtCoder Beginner Contest 142 - Disjoint Set of Common Divisors

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

-----Sample Output-----
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.

Source: atcoder | Difficulty: MEDIUM


Solutions:
from fractions import *
n = gcd(*map(int, input().split()))
ans = 1
i = 1
while i * i < n:
	i += 1
	if n % i == 0:
		ans += 1
	while n % i < 1:
		n /= i
print(ans + (n > 1))


import itertools
import sys
(a, b) = list(map(int, input().split()))

def gcd(A, B):
	while B != 0:
		(A, B) = (B, A % B)
	return A

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


(a, b) = map(int, input().split())
while a % b != 0:
	(a, b) = (b, a % b)
ans = 1
if b % 2 == 0:
	ans += 1
	while b % 2 == 0:
		b = b // 2
for i in range(3, int(b ** 0.5) + 1, 2):
	if b % i == 0:
		ans += 1
		while b % i == 0:
			b = b // i
if b != 1:
	ans += 1
print(ans)


from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque, Counter, defaultdict
from operator import mul
import copy
import heapq
sys.setrecursionlimit(10 ** 6)
INF = 10 ** 18
import bisect
import statistics
mod = 10 ** 9 + 7
import numpy
(A, B) = map(int, input().split())

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


import math

def fctr1(n):
	f = []
	c = 0
	r = int(n ** 0.5)
	for i in range(2, r + 2):
		while n % i == 0:
			c += 1
			n = n // i
		if c != 0:
			f.append([i, c])
			c = 0
	if n != 1:
		f.append([n, 1])
	return f
(a, b) = map(int, input().split())
print(len(fctr1(math.gcd(a, b))) + 1)


import math

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

def main():
	(A, B) = [int(x) for x in input().split(' ')]
	g = math.gcd(A, B)
	pg = prime_factorize(g)
	if pg[0][0] == 1:
		print(1)
	else:
		print(len(pg) + 1)
main()


import sys
from io import StringIO
import unittest
import collections

def yn(b):
	print('Yes' if b == 1 else 'No')
	return

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 resolve():
	readline = sys.stdin.readline
	(a, b) = list(map(int, readline().rstrip().split()))
	af = factorization(a)
	bf = factorization(b)
	c = collections.Counter()
	c[1] = 2
	for x in af:
		c[x[0]] += 1
	for x in bf:
		c[x[0]] += 1
	ans = 0
	for k in list(c.keys()):
		if c[k] >= 2:
			ans += 1
	print(ans)
	return
if 'doTest' not in globals():
	resolve()
	return


from fractions import gcd
from math import sqrt
(a, s) = map(int, input().split())
f = gcd(a, s)
ans = 1
if f <= 3:
	print(1 + (f != 1))
	exit()
for i in range(2, int(sqrt(f)) + 1):
	if f % i == 0:
		ans += 1
		while f % i == 0:
			f //= i
print(ans + (f != 1))


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(a, b) = [int(x) for x in input().split(' ')]
g = gcd(a, b)
ret = 1
i = 2
while i * i <= g:
	if g % i == 0:
		while g % i == 0:
			g /= i
		ret += 1
	i += 1
if g > 1:
	ret += 1
print(ret)


from fractions import *
g = gcd(*map(int, input().split()))
c = 1
for i in range(2, int(g ** 0.5) + 1):
	if g < 2:
		break
	if g % i < 1:
		c += 1
	while g % i < 1:
		g //= i
print(c + (g > 1))


import math

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())
c = math.gcd(a, b)
print(len(set(prime_factorize(c))) + 1)


from fractions import gcd
(a, b) = map(int, input().split())
g = gcd(a, b)
ans = 1
if g % 2 == 0:
	ans += 1
while g % 2 == 0:
	g /= 2
i = 3
while i * i <= g:
	if g % i == 0:
		ans += 1
	while g % i == 0:
		g /= i
	i += 2
if g != 1:
	ans += 1
print(ans)


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

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
d = gcd(a, b)
pf = {}
for i in range(2, int(d ** 0.5) + 1):
	while d % i == 0:
		pf[i] = pf.get(i, 0) + 1
		d //= i
if d > 1:
	pf[d] = 1
P = list(pf.keys())
print(len(P) + 1)


from fractions import gcd
(a, b) = map(int, input().split())
g = gcd(a, b)
l = []
for i in range(2, int(g ** 0.5) + 1):
	while g % i == 0:
		l.append(i)
		g //= i
if g > 1:
	l.append(g)
print(len(set(l)) + 1)


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


from math import gcd
(a, b) = list(map(int, input().split()))

def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
v = gcd(a, b)
divs = make_divisors(v)
k = 1
ans = 0
for d in divs:
	test = gcd(k, d)
	if test == 1:
		ans += 1
		k *= d
print(ans)


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)


def main():
	import math
	(a, b) = list(map(int, input().split()))
	g = math.gcd(a, b)
	ans = [1]
	for m in range(2, int(g ** 0.5) + 1):
		if g % m == 0:
			ans.append(m)
			while g % m == 0:
				g = g // m
		if g == 1:
			break
	if g != 1:
		ans.append(g)
	print(len(ans))

def __starting_point():
	main()
__starting_point()


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


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

def prime_factorization(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
Aprimes = prime_factorization(A)
Bprimes = set(prime_factorization(B))
ans = 1
ansset = set()
for a in Aprimes:
	if a in ansset:
		continue
	if a in Bprimes:
		ansset.add(a)
		ans += 1
print(ans)


(a, b) = map(int, input().split())
from fractions import gcd
n = gcd(a, b)
i = 2
primes = []
while True:
	if i > 10 ** 6 + 1:
		break
	if n % i == 0:
		n //= i
		primes.append(i)
	else:
		i += 1
print(len(set(primes)) + (n != 1) + 1)


def c(n):
	b = 2
	f = set()
	while b * b <= n:
		while n % b == 0:
			n //= b
			f |= {b}
		b += 1
	if n > 1:
		f |= {n}
	return f
(a, b) = map(int, input().split())
print(len(c(a) & c(b)) + 1)


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


def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
(a, b) = map(int, input().split())
p = gcd(a, b)
s = {1}
for i in range(2, int(p ** 0.5) + 2):
	if p % i == 0:
		s.add(i)
		p //= i
		while p % i == 0:
			p //= i
if p > 1:
	s.add(p)
print(len(s))


from fractions import gcd

def prime_factors(n):
	i = 2
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			yield i
	if n > 1:
		yield n
(A, B) = map(int, input().split())
g = gcd(A, B)
print(1 + len(set(prime_factors(g))))


(a, b) = map(int, input().split())
c = 1
for i in range(2, int(max(a ** 0.5, b ** 0.5)) + 2):
	if a % i == 0 == b % i:
		c += 1
	while a % i == 0:
		a //= i
	while b % i == 0:
		b //= i
if a == b != 1:
	c += 1
print(c)


from math import *
from copy import deepcopy
(A, B) = map(int, input().split())
C = gcd(A, B)
E = deepcopy(C)
D = set()
for i in range(2, floor(sqrt(E)) + 1):
	while True:
		if C / i != C / i // 1:
			break
		D.add(i)
		C /= i
if C != 1:
	D.add(int(C))
print(len(D) + 1)


from fractions import *
n = gcd(*map(int, input().split()))
a = 1
i = 2
while i * i <= n:
	a += n % i < 1
	while n % i < 1:
		n //= i
	i += 1
print(a + (n > 1))


from fractions import gcd
(A, B) = map(int, input().split())
s = set()
x = gcd(A, B)
y = 2
while y * y <= x:
	while x % y == 0:
		s.add(y)
		x //= y
	y += 1
if x > 1:
	s.add(x)
print(len(s) + 1)


(a, b) = map(int, input().split())
g = 1
while 1:
	if a == b:
		g = a
		break
	if a < b:
		k = a
		a = b
		b = k
	a -= b
ans = 1
i = 2
while i * i <= g:
	if g % i == 0:
		ans += 1
		while g % i == 0:
			g //= i
	i += 1
if g != 1:
	ans += 1
print(ans)


import math
(a, b) = map(int, input().split())
gcd = math.gcd(a, b)

def prime_factorization(n):
	i = 2
	prime = []
	if n % i == 0:
		n //= i
		prime.append(2)
		while n % i == 0:
			n //= i
	i += 1
	while i * i <= n:
		if n % i:
			i += 2
		else:
			n //= i
			prime.append(i)
			while n % i == 0:
				n //= i
	if n > 1:
		prime.append(n)
	return prime
print(len(prime_factorization(gcd)) + 1)


import fractions
(A, B) = map(int, input().split())
G = fractions.gcd(A, B)
res = 1
for i in [2] + list(range(3, int(G ** 0.5) + 1, 2)):
	if G % i == 0:
		res += 1
		while G % i == 0:
			G //= i
if G > 2:
	res += 1
print(res)


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)


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


def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
(a, b) = map(int, input().split())
g = gcd(a, b)
count = 0
for i in range(2, int(g ** 0.5) + 2):
	if g % i == 0:
		count += 1
		while g % i == 0:
			g //= i
if g != 1:
	count += 1
print(count + 1)


from math import gcd
from typing import List, Tuple

def pf(n: int) -> List[Tuple[int, int]]:
	r = []
	for p in range(2, n):
		if p * p > n:
			break
		e = 0
		if n % p == 0:
			while n % p == 0:
				n //= p
				e += 1
			r.append((p, e))
	if n != 1:
		r.append((n, 1))
	return r
(a, b) = map(int, input().split())
apf = pf(a)
bpf = pf(b)
aps = {p for (p, e) in apf}
bps = {p for (p, e) in bpf}
print(len(aps & bps) + 1)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(a, b) = map(int, input().split())
g = gcd(a, b)
m = g
c = 1
i = 2
while i * i <= g:
	if m % i == 0:
		c += 1
	while m % i == 0:
		m = m // i
	i += 1
if m > 1:
	c += 1
print(c)


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

def prime_decomposition(x):
	i = 2
	ls = []
	while i * i <= x:
		while x % i == 0:
			x /= i
			ls.append(i)
		i += 1
	if x > 1:
		ls.append(x)
	return ls
cnt = len(set(prime_decomposition(x)))
print(cnt + 1)


from fractions import gcd
(a, b) = map(int, input().split())
GCD = gcd(a, b)
ans = 1
for i in range(2, int(GCD ** 0.5) + 1):
	if GCD % i == 0:
		ans += 1
	while GCD % i == 0:
		GCD //= i
if GCD != 1:
	ans += 1
print(ans)


import math

def factorize(n):
	V = [1]
	if n == 1:
		return V
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			V.append(i)
			while n % i == 0:
				n //= i
	if n > 1:
		V.append(n)
	return V
(A, B) = [int(x) for x in input().split()]
V = factorize(math.gcd(A, B))
print(len(V))


from math import sqrt
from fractions import gcd
(A, B) = list(map(int, input().split()))
N = gcd(A, B)
ans = set()
for i in range(2, int(1000000.0 + 100)):
	if N == 1:
		break
	while N % i == 0:
		ans.add(i)
		N /= i
if N > 1:
	ans.add(N)
print(len(ans) + 1)


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

def prime_d(n):
	i = 2
	t = []
	while i * i <= n:
		while n % i == 0:
			n /= i
			t.append(i)
		i += 1
	if n > 1:
		t.append(n)
	return t
l = set(prime_d(a))
m = set(prime_d(b))
print(len(l & m) + 1)


from math import gcd
(A, B) = map(int, input().split())
d = gcd(A, B)
ans = 1
i = 2
while i <= pow(d, 1 / 2) + 1:
	if d % i == 0:
		ans += 1
		while d % i == 0:
			d //= i
	i += 1
ans += d > 1
print(ans)


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


from functools import lru_cache

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

@lru_cache(maxsize=None)
def primes(n: int) -> list:
	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
	return [i for i in range(n + 1) if is_prime[i]]

@lru_cache(maxsize=None)
def is_prime(n: int) -> bool:
	if n == 1:
		return False
	elif n == 2:
		return True
	elif n % 2 == 0:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

@lru_cache(maxsize=None)
def prime_factorize(n: int) -> list:
	arr = []
	while n % 2 == 0:
		arr.append(2)
		n //= 2
	for f in primes(int(n ** 0.5)):
		while n % f == 0:
			arr.append(f)
			n //= f
	if n != 1:
		arr.append(n)
	return arr

def make_divisors(n: int) -> list:
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]

def __starting_point():
	main()
__starting_point()


def gcd(a, b):
	return gcd(b, a % b) if b else a
(a, b) = map(int, input().split())
c = gcd(a, b)
ans = 1
cnt = 2
while cnt * cnt < c:
	bo = False
	while c % cnt == 0:
		if not bo:
			ans += 1
			bo = True
		c //= cnt
	cnt += 1
if c != 1:
	ans += 1
print(ans)


from fractions import gcd
from math import sqrt
(A, B) = map(int, input().split())
n = gcd(A, B)
ans = set()
for i in range(2, int(sqrt(n) + 1) + 1):
	while n % i == 0:
		n = n // i
		ans.add(i)
if n > 1:
	ans.add(n)
print(len(ans) + 1)


import math

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

def div(n):
	cnt = 0
	temp = n
	for i in range(2, int(math.sqrt(n)) + 1):
		if temp % i == 0:
			while temp % i == 0:
				temp //= i
			cnt += 1
	if temp != 1:
		cnt += 1
	return cnt + 1
(a, b) = map(int, input().split())
print(div(gcd(a, b)))


(x, y) = map(int, input().split())
if x < y:
	(x, y) = (y, x)
while x % y != 0:
	(x, y) = (y, x % y)
ans = 1
for i in range(2, int(y ** 0.5) + 1):
	if y % i == 0:
		ans += 1
		while y % i == 0:
			y //= i
if y > 1:
	ans += 1
print(ans)


import sys
import math
import itertools
import collections
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().strip()
NI = lambda : int(input())
NMI = lambda : map(int, input().split())
NLI = lambda : list(NMI())
SI = lambda : input()

def main():
	(A, B) = NMI()
	GCD = math.gcd(A, B)
	N = GCD
	cnt = 0
	ls = []
	for n in range(2, int(N ** 0.5) + 2):
		if GCD % n == 0:
			cnt += 1
			while GCD % n == 0:
				GCD = GCD // n
				ls.append(n)
	if GCD == 1:
		print(cnt + 1)
	else:
		print(cnt + 2)

def __starting_point():
	main()
__starting_point()


from fractions import gcd
(a, b) = map(int, input().split())
g = gcd(a, b)
ans = {}
for i in range(2, int(g ** 0.5 + 1)):
	while g % i == 0:
		ans[i] = ans[i] + 1 if i in ans else 1
		g //= i
if g != 1:
	ans[g] = 1
print(len(ans) + 1)


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

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

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


def GCD(x, y):
	if y == 0:
		return x
	return GCD(y, x % y)
(A, B) = map(int, input().split())
g = GCD(A, B)
ans = 1
for i in range(2, int(g ** 0.5) + 1):
	if g % i == 0:
		ans += 1
		while g % i == 0:
			g //= i
if g != 1:
	ans += 1
print(ans)


(N, M) = (int(i) for i in input().split(' '))
(N, M) = (min(M, N), max(M, N))
while M % N != 0:
	M = M % N
	(N, M) = (min(M, N), max(M, N))
i = 2
ans = 0
DN = N
while i * i <= DN:
	if N % i == 0:
		ans += 1
		while N % i == 0:
			N /= i
	i += 1
if i <= N:
	ans += 1
print(ans + 1)


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


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


from fractions import gcd
(A, B) = map(int, input().split())
C = gcd(A, B)
ans = 1
i = 2
for i in range(2, int(-(-C ** 0.5 // 1)) + 1):
	if C % i == 0:
		ans += 1
		while C % i == 0:
			C //= i
	i += 1
if C != 1:
	ans += 1
print(ans)


(a, b) = list(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
a_prime = set(prime_factorize(a))
b_prime = set(prime_factorize(b))
ans = 0
for ap in a_prime:
	for bp in b_prime:
		if ap == bp:
			ans += 1
			break
print(ans + 1)


(N, M) = list(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
a = prime_factorize(N)
b = prime_factorize(M)
c = set(a) & set(b)
print(len(c) + 1)


from fractions import gcd
(a, b) = [int(i) for i in input().split()]
res = set()
x = gcd(a, b)
y = 2
while y * y <= x:
	while x % y == 0:
		res.add(y)
		x //= y
	y += 1
if x > 1:
	res.add(x)
print(len(res) + 1)


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

def prime_factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append(i)
	if temp != 1:
		arr.append(temp)
	if arr == []:
		arr.append(n)
	return arr
setA = set(prime_factorization(A))
setB = set(prime_factorization(B))
setAB = setA & setB
if setAB == {1}:
	print(1)
else:
	print(len(setAB) + 1)


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def get_primenumber(number):
	prime_list = []
	search_list = list(range(2, number + 1))
	while search_list[0] <= math.sqrt(number):
		head_num = search_list.pop(0)
		prime_list.append(head_num)
		search_list = [num for num in search_list if num % head_num != 0]
	prime_list.extend(search_list)
	return prime_list

def factrization_prime(number):
	factor = {}
	div = 2
	s = math.sqrt(number)
	while div < s:
		div_cnt = 0
		while number % div == 0:
			div_cnt += 1
			number //= div
		if div_cnt != 0:
			factor[div] = div_cnt
		div += 1
	if number > 1:
		factor[number] = 1
	return factor

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

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

def X():
	return list(input())

def L():
	return list(input().split())

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

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 6)
mod = 10 ** 9 + 7
cnt = 0
ans = 0
num = []
inf = float('inf')
al = 'abcdefghijklmnopqrstuvwxyz'
AL = al.upper()
(a, b) = I()
prime_a = factrization_prime(a)
prime_b = factrization_prime(b)
for i in prime_a.keys():
	if i in prime_b.keys():
		cnt += 1
print(cnt + 1)


import fractions
(a, b) = map(int, input().split())
x = fractions.gcd(a, b)
t = x
i = 2
ans = 1
while i * i <= t:
	if x % i == 0:
		while x % i == 0:
			x /= i
		ans += 1
	i += 1
if x != 1:
	ans += 1
print(ans)


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)


from math import gcd, sqrt
(a, b) = map(int, input().split())
g = gcd(a, b)
d = {}
for i in range(2, int(sqrt(g)) + 1):
	while g % i == 0:
		g //= i
		d[i] = d.get(i, 0) + 1
if g > 1:
	d[g] = 1
print(len(d) + 1)


import fractions
import math
(A, B) = map(int, input().split())
x = fractions.gcd(A, B)
l = []
for i in range(2, math.floor(math.sqrt(x)) + 1):
	count = 0
	while x % i == 0:
		count += 1
		x /= i
	if count >= 1:
		l.append([i, count])
if x > math.floor(math.sqrt(x)):
	l.append([x, 1])
print(len(l) + 1)


import math
(a, b) = map(int, input().split())
x = math.gcd(a, b)
s = [1]
for i in range(2, int(math.sqrt(x) + 1)):
	if x % i == 0:
		while x % i == 0:
			x //= i
		s.append(i)
if x != 1:
	s.append(x)
l = len(s)
print(l)


(a, b) = map(int, input().split())
sa = set()
sb = set()
i = 1
while i * i <= max(a, b):
	if a % i == 0:
		sa.add(i)
		sa.add(a // i)
	if b % i == 0:
		sb.add(i)
		sb.add(b // i)
	i += 1
s = sa & sb
s.remove(1)
for x in list(s):
	for y in list(s):
		if x == y:
			continue
		if y % x == 0:
			s.remove(y)
print(len(s) + 1)


import fractions
(a, b) = map(int, input().split())
gcd = fractions.gcd(a, b)
count = 1
for i in range(2, int(gcd ** 0.5) + 1):
	if gcd % i == 0:
		count += 1
	while gcd % i == 0:
		gcd //= i
if gcd != 1:
	count += 1
print(count)


def gcd(a, b):
	while a % b != 0:
		return gcd(b, a % b)
	return b
(A, B) = (int(x) for x in input().split())
Gcd = gcd(A, B)
lo_cds = []
up_cds = []
i = 1
while i * i <= Gcd:
	if Gcd % i == 0:
		lo_cds.append(i)
		if Gcd // i != i:
			up_cds.append(Gcd // i)
	i += 1
Cds = lo_cds + up_cds[::-1]
Cds.pop(0)
i = 0
while i < len(Cds):
	j = i + 1
	while j < len(Cds):
		if Cds[j] % Cds[i] == 0:
			Cds.pop(j)
		else:
			j += 1
	i += 1
print(len(Cds) + 1)


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)


import fractions
(a, b) = (int(i) for i in input().split())
m = fractions.gcd(a, b)
pf = {}
for i in range(2, int(m ** 0.5) + 1):
	while m % i == 0:
		pf[i] = pf.get(i, 0) + 1
		m //= i
if m > 1:
	pf[m] = 1
print(len(pf) + 1)


from fractions import *
g = gcd(*map(int, input().split()))
d = {}
i = 2
while i * i <= g:
	if g % i:
		i += 1
	else:
		g //= i
		d[i] = d.get(i, 0) + 1
if g > 1:
	d[g] = d.get(g, 0) + 1
print(len(d) + 1)


import math

def trial_division(n):
	factor = []
	tmp = int(math.sqrt(n)) + 1
	for num in range(2, tmp):
		while n % num == 0:
			n //= num
			factor.append(num)
	if not factor:
		factor.append(1)
		factor.append(n)
		return factor
	else:
		factor.append(1)
		factor.append(n)
		return factor
(A, B) = list(map(int, input().split()))
A_primes = trial_division(A)
B_primes = trial_division(B)
primes = []
for p in A_primes:
	if p in B_primes:
		primes.append(B_primes.pop(B_primes.index(p)))
print(len(list(set(primes))))


import math

def factorization(n):
	arr = [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)
	if temp != 1:
		arr.append(temp)
	if not arr:
		arr.append(n)
	return arr
(A, B) = list(map(int, input().split()))
gcd = math.gcd(A, B)
f = factorization(gcd)
print(len(f))


def factrization(n):
	arr = []
	temp = n
	for i in range(2, int(n ** 0.5 // 1) + 2):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append(i)
	if temp != 1:
		arr.append(temp)
	if arr == []:
		arr.append(n)
	return arr
(a, b) = map(int, input().split())
ans = 0
la = factrization(a)
lb = factrization(b)
if 1 not in la:
	la.append(1)
if 1 not in lb:
	lb.append(1)
for i in la:
	if i in lb:
		ans += 1
print(ans)


import sys
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_ints2(x):
	return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

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

def LCM(a: int, b: int) -> int:
	return a * b // GCD(a, b)

def factorization(num):
	prime = []
	n = num
	p = 2
	while p * p <= num:
		if n % p == 0:
			cnt = 0
			while n % p == 0:
				cnt += 1
				n //= p
			prime.append((p, cnt))
		p += 1
	if n != 1:
		prime.append((n, 1))
	if not prime:
		prime.append((num, 1))
	return prime

def Main():
	(a, b) = read_ints()
	g = GCD(a, b)
	if g == 1:
		print(1)
		return
	prime = factorization(g)
	print(len(prime) + 1)

def __starting_point():
	Main()
__starting_point()


import math

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(pow(n, 1 / 2)) + 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())
gcd_num = math.gcd(A, B)
if gcd_num == 1:
	print(1)
else:
	print(len(factorization(gcd_num)) + 1)


(n, m) = 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 = sorted(list(set(table)))
	return table

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
s = set(divisor(n)).intersection(set(divisor(m)))
ans = 1
for ss in s:
	if len(prime_factorize(ss)) == 1:
		ans += 1
print(ans)


from fractions import *
g = gcd(*map(int, input().split()))
c = i = 1
while i * i <= g and g > 1:
	i += 1
	c += g % i < 1
	while g % i < 1:
		g /= i
print(c + (g > 1))


import math
(a, b) = map(int, input().split())
while b != 0:
	(a, b) = (b, a % b)
n = a
rn = int(math.sqrt(n))
cnt = 1
for i in range(2, rn + 1):
	if n % i == 0:
		while n % i == 0:
			n = n // i
		cnt += 1
if n == 1:
	print(cnt)
else:
	print(cnt + 1)


(A, B) = map(int, input().split())
(a, b) = (A, B)
while b != 0:
	(a, b) = (b, a % b)
prod = 1
s = 1
p = 2
g = a
while a != 1:
	i = 0
	while a % p == 0:
		i += 1
		a //= p
		prod *= p
	if i != 0:
		s += 1
	p += 1
	if p > int(g ** (1 / 2)) and prod != g:
		s += 1
		break
print(s)


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

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)
n = gcd(a, b)
ans = 0
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 + 1)


import fractions as fra
import math
(a, b) = map(int, input().split())
n = fra.gcd(a, b)
tmp = int(math.sqrt(n)) + 1
l = [1]
ans = 0
for i in range(2, tmp):
	while n % i == 0:
		n //= i
		if i not in l:
			l.append(i)
			ans += 1
if n not in l:
	ans += 1
print(ans + 1)


import math
from math import gcd
(A, B) = map(int, input().split())
g = gcd(A, B)
n = int(math.sqrt(g))
d_list = list()
for i in range(1, n + 1):
	if g % i == 0:
		j = g // i
		d_list.append(i)
		if j != 1:
			d_list.append(j)
d_list.sort()
ans_list = [1]
d_list.pop(0)
while d_list:
	t = d_list.pop(0)
	ans_list.append(t)
	d_list = [i for i in d_list if i % t != 0]
print(len(ans_list))


from fractions import gcd
from math import ceil, sqrt
(a, b) = map(int, input().split())
g = gcd(a, b)
s = set()
for i in range(2, ceil(sqrt(g)) + 1):
	while g % i == 0:
		g //= i
		s.add(i)
if g != 1:
	s.add(int(100000000000000.0))
print(len(s) + 1)


from fractions import gcd
d = gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
	c = 0
	while d % i == 0:
		c += 1
		d //= i
	if c:
		r += 1
	i += 1
print(r + (d > 1))


(a, b) = map(int, input().split())
(m, n) = (a, b)
c = 0
while n != 0:
	c = m % n
	m = n
	n = c
li = [1]
for i in range(2, int(m ** 0.5) + 1):
	while m % i == 0:
		m //= i
		li.append(i)
li.append(m)
print(len(set(li)))


import math
(a, b) = (int(x) for x in input().split())
saidai = 1

def yakusuu(x, y):
	return (y, x % y)

def cont(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
saidai = math.gcd(a, b)
d = cont(saidai)
if d[0] == [1, 1]:
	print(1)
	return
print(len(d) + 1)


import math
import collections

def prime_factorize(n):
	s = []
	while n % 2 == 0:
		s.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			s.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		s.append(n)
	return s
(a, b) = map(int, input().split())
g = math.gcd(a, b)
c = collections.Counter(prime_factorize(g))
print(len(c.values()) + 1)


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


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

def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	if b == 0:
		return a
	while b > 0:
		r = a % b
		a = b
		b = r
	return a
g = gcd(a, b)
x = g
s = set()
for i in range(2, int(math.sqrt(g)) + 1):
	while x % i == 0:
		s.add(i)
		x /= i
if x != 1:
	s.add(x)
print(len(s) + 1)


def factorize(n):
	fct = []
	(b, e) = (2, 0)
	while b * b <= n:
		while n % b == 0:
			n //= b
			e += 1
		if e > 0:
			fct.append((b, e))
		(b, e) = (b + 1, 0)
	if n > 1:
		fct.append((n, 1))
	return fct
(a, b) = map(int, input().split())
ap = set()
for (prime, count) in factorize(a):
	ap.add(prime)
bp = set()
for (prime, count) in factorize(b):
	bp.add(prime)
print(len(ap & bp) + 1)


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


import math
(a, b) = map(int, input().split())
t = math.gcd(a, b)

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
cnt = len(set(prime_decomposition(t)))
print(cnt + 1)


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)


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


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

def gcd(x, y):
	while y != 0:
		cur = x
		x = y
		y = cur % y
	return x
t = gcd(a, b)
L = []
for i in range(2, 10 ** 6 + 1):
	while t % i == 0:
		t = t // i
		if i not in L:
			L.append(i)
if t != 1:
	L.append(t)
print(len(L) + 1)


(a, b) = map(int, input().split())
ans = 1
for i in range(2, int(min(a, b) ** 0.5) + 1):
	if a % i == 0 and b % i == 0:
		ans += 1
	while a % i == 0:
		a //= i
	while b % i == 0:
		b //= i
if a != 1 and b != 1 and (a % b == 0 or b % a == 0):
	ans += 1
print(ans)


from fractions import gcd
(A, B) = map(int, input().split())
G = gcd(A, B)
a = 1
for i in range(2, 10 ** 6 + 1):
	t = 0
	while 1:
		if G % i == 0:
			G //= i
			t += 1
		else:
			break
	if t:
		a += 1
if G > 10 ** 6:
	a += 1
print(a)


from math import ceil
from fractions import gcd
(a, b) = map(int, input().split())
c = gcd(a, b)
count = 1
for num in range(2, ceil(c ** 0.5) + 1):
	if c % num == 0:
		count += 1
		while c % num == 0:
			c = c // num
if c > 1:
	count += 1
print(count)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(a, b) = map(int, input().split())
n = gcd(a, b)
primes = []
MAX = 10 ** 6 + 10
is_prime = [False] * 2 + [True] * (MAX - 2)
for i in range(2, MAX):
	if is_prime[i]:
		primes.append(i)
		for j in range(i * i, MAX, i):
			is_prime[j] = False
cnt = 1
for p in primes:
	if n % p == 0:
		cnt += 1
		while n % p == 0:
			n /= p
if n != 1:
	cnt += 1
print(cnt)


def primeFact(n):
	i = 2
	pl = []
	while i * i <= n:
		while n % i == 0:
			n /= i
			pl.append(i)
		i += 1
	if n > 1:
		pl.append(int(n))
	return pl
(a, b) = map(int, input().split())
print(len(set(primeFact(a)) & set(primeFact(b))) + 1)


url = 'https://atcoder.jp//contests/abc142/tasks/abc142_d'
import math

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

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

def __starting_point():
	main()
__starting_point()


import fractions
(a, b) = map(int, input().split())
b = fractions.gcd(a, b)
c = 0
a = 0
for i in range(2, 1000001):
	while b % i == 0:
		b //= i
		a = 1
	if a:
		c += 1
	a = 0
	if b == 1:
		break
if b != 1:
	c += 1
print(c + 1)


def prefactor(x):
	ret = set()
	for i in range(2, int(x ** 0.5) + 1):
		if x % i == 0:
			ret.add(i)
		while x % i == 0:
			x //= i
	if x > 1:
		ret.add(x)
	return ret
(a, b) = map(int, input().split())
print(1 + len(prefactor(a) & prefactor(b)))


import math

def factrize(num):
	factor = {}
	div = 2
	s = int(num ** 0.5) + 1
	while div < s:
		div_cnt = 0
		while num % div == 0:
			div_cnt += 1
			num //= div
		if div_cnt != 0:
			factor[div] = div_cnt
		div += 1
	if num > 1:
		factor[num] = 1
	return factor
(a, b) = map(int, input().split())
g = math.gcd(a, b)
print(len(factrize(g)) + 1)


from math import gcd

def division(n):
	if n < 2:
		return [1]
	prime_factors = [1]
	for i in range(2, int(n ** 0.5) + 1):
		while n % i == 0:
			prime_factors.append(i)
			n //= i
	if n > 1:
		prime_factors.append(n)
	return prime_factors
(a, b) = map(int, input().split())
d = set(division(gcd(a, b)))
print(len(d))


s = set

def f(n):
	a = 2
	t = []
	while a * a <= n:
		while n % a == 0:
			n //= a
			t.append(a)
		a += 1
	if n > 1:
		t.append(n)
	return t
(a, b) = map(int, input().split())
print(len(s(f(a)) & s(f(b))) + 1)


(A, B) = map(int, input().split())
Pa = {1}
Pb = {1}
a = 2
while a * a <= A:
	if A % a == 0:
		A = A // a
		Pa.add(a)
	else:
		a += 1
if A > 1:
	Pa.add(A)
b = 2
while b * b <= B:
	if B % b == 0:
		B = B // b
		Pb.add(b)
	else:
		b += 1
if B > 1:
	Pb.add(B)
print(len(Pa & Pb))


import math
(a, b) = map(int, input().split())
n = math.gcd(a, b)
cnt = 1
f = 2
d = n
while f * f <= n:
	if d % f == 0:
		cnt += 1
		while d % f == 0:
			d = d // f
	f += 1
if d != 1:
	cnt += 1
print(cnt)


import fractions
(A, B) = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
if gcd > 1:
	fact = 2
	tmp = gcd
	while fact * fact <= gcd:
		if tmp % fact == 0:
			ans += 1
			while tmp % fact == 0:
				tmp //= fact
		fact += 1
	if tmp > 1:
		ans += 1
print(ans)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
import math
(a, b) = map(int, input().split())
x = gcd(a, b)
c = x
ans = 1
for i in range(2, int(math.sqrt(x)) + 1):
	if c % i == 0:
		ans += 1
	while c % i == 0:
		c = c // i
if c > 1:
	ans += 1
print(ans)


(a, b) = list(map(int, input().split()))
if a == 1 and b == 1:
	print(1)
	return

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
ans = 0
A = factorization(a)
B = factorization(b)
for i in A:
	for j in B:
		if i[0] == j[0]:
			ans += 1
print(ans + 1)


import fractions
(a, b) = map(int, input().split())
g = fractions.gcd(a, b)
res = 1
x = 2
while x * x <= g:
	if g % x == 0:
		res += 1
		while g % x == 0:
			g //= x
	x += 1
print(res + int(g != 1))


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

def prime(n):
	i = 2
	table = []
	while i * i <= n:
		while n % i == 0:
			n = n // i
			table.append(i)
		i += 1
	if n > 1:
		table.append(n)
	return table
print(len(list(set(prime(a)).intersection(set(prime(b))))) + 1)


(n, m) = map(int, input().split())
while m:
	(n, m) = (m, n % m)
pf = {}
for i in range(2, int(n ** 0.5) + 1):
	while n % i == 0:
		pf[i] = pf.get(i, 0) + 1
		n //= i
if n > 1:
	pf[n] = 1
if pf == {}:
	print(1)
else:
	print(len(pf) + 1)


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

def ela(g):
	s = {1}
	i = 2
	while i * i <= g:
		while g % i == 0:
			g //= i
			s.add(i)
		i += 1
	if g != 1:
		s.add(g)
	return s
(a, b) = map(int, input().split())
G = gcd(max(a, b), min(a, b))
print(len(ela(G)))


import math

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

def count_prime_factorize(n):
	res = 1
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			res += 1
			while n % i == 0:
				n //= i
		i += 1
	if n != 1:
		res += 1
	return res
(a, b) = list(map(int, input().strip().split()))
x = gcd(a, b)
res = count_prime_factorize(x)
print(res)


import math

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

def __starting_point():
	main()
__starting_point()


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

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


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

def prime_factorization(n):
	if n == 1:
		return [1]
	else:
		i = 2
		ans = []
		k = int(n ** 0.5) + 1
		for j in range(2, k + 1):
			if n == 1:
				break
			if n % j == 0:
				n //= j
				ans.append(j)
				while n % j == 0:
					n //= j
		if len(ans):
			ans.append(1)
			if n != 1:
				ans.append(n)
			return ans
		else:
			return [1, n]
A = prime_factorization(a)
B = prime_factorization(b)
print(len(set(A) & set(B)))


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)


from fractions import gcd
from math import sqrt
(a, b) = map(int, input().split())
n = gcd(a, b)
k = n
s = set()
s.add(1)
for i in range(2, int(sqrt(n)) + 1):
	while n % i == 0:
		n = n // i
		s.add(i)
	if n == 1:
		break
s.add(n)
print(len(s))


(A, B) = map(int, input().split())
import math
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
c = prime_factorize(math.gcd(A, B))
c = collections.Counter(c)
c = c.values()
print(len(c) + 1)


def f(n):
	ret = {1}
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			ret.add(i)
			while n % i == 0:
				n //= i
		else:
			pass
	if n:
		ret.add(n)
	return ret
(a, b) = map(int, input().split())
print(len(f(a) & f(b)))


(a, b) = map(int, input().split())
import fractions
import math
n = fractions.gcd(a, b)
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)
print(len(set(a)) + 1)


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

def prime(N):
	lsprime = [0, 0] + [1 for i in range(N - 1)]
	lsprime2 = []
	for i in range(N + 1):
		if lsprime[i] == 0:
			continue
		lsprime2.append(i)
		k = i
		while i <= N:
			lsprime[i] = 0
			i += k
	return lsprime2

def prime2(N):
	arr = []
	temp = N
	setprime = set()
	for i in range(2, int(-(-N ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			setprime.add(i)
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append([i, cnt])
	if temp != 1:
		arr.append([temp, 1])
		setprime.add(temp)
	if arr == []:
		arr.append([N, 1])
	return (arr, setprime)
(_, setp) = prime2(C)
print(len(setp) + 1)


(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
A = set(prime_factorize(a))
B = set(prime_factorize(b))
cnt = 0
for i in A:
	if i in B:
		cnt += 1
print(cnt + 1)


from collections import Counter
from fractions import gcd
(a, b) = map(int, input().split())
n = int(max(a, b) ** (1 / 2)) + 1
g = gcd(a, b)
cnt = Counter()
m = 2
while m * m <= g:
	while g % m == 0:
		g //= m
		cnt[m] += 1
	m += 1
if g > 1:
	cnt[g] += 1
print(len(cnt) + 1)


from math import gcd

def resolve():

	def prime_factorize(n):
		if 2 <= n < 4:
			return [n]
		res = []
		i = 2
		while i * i <= n:
			while n % i == 0:
				res.append(i)
				n //= i
			i += 1
		if n != 1:
			res.append(n)
		return set(res)
	(a, b) = list(map(int, input().split()))
	g = gcd(a, b)
	ans = prime_factorize(g)
	print(len(ans) + 1)

def __starting_point():
	resolve()
__starting_point()


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

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


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

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	else:
		return gcd(b, a % b)
p = gcd(a, b)
factors = {}
while p > 1:
	f = False
	for i in range(2, int(p ** 0.5) + 1):
		if p % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			p //= i
			f = True
			break
	if not f:
		if p in factors:
			factors[p] += 1
		else:
			factors[p] = 1
		break
print(len(factors) + 1)


from fractions import gcd
(A, B) = map(int, input().split())
x = gcd(A, B)
prime = set()
prime.add(1)
for i in range(2, int(x ** 0.5) + 1):
	while x % i == 0:
		prime.add(i)
		x //= i
if x != 1:
	prime.add(x)
print(len(prime))


import fractions as fc
(A, B) = [int(x) for x in input().split()]
C = fc.gcd(A, B)
b = 2
ans = 1
while b * b <= C:
	if C % b == 0:
		ans += 1
		while C % b == 0:
			C //= b
	if C == 1:
		break
	b += 1
if C > 1:
	ans += 1
print(ans)


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

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

def factorize(x):
	i = 2
	res = []
	while i * i <= x:
		while x % i == 0:
			x //= i
			res.append(i)
		i += 1
	if x > 1:
		res.append(x)
	return res
g = gcd(a, b)
f = factorize(g)
print(len(set(f)) + 1)


(a, b) = map(int, input().split())
A = [1]
for i in range(2, int(a ** 0.5) + 1):
	if a % i == 0:
		while a % i == 0:
			a //= i
		A.append(i)
if a > 1:
	A.append(a)
B = [1]
for i in range(2, int(b ** 0.5) + 1):
	if b % i == 0:
		while b % i == 0:
			b //= i
		B.append(i)
if b > 1:
	B.append(b)
can = 0
for i in A:
	if i in B:
		can += 1
print(can)


def GCD(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(a, b) = map(int, input().split())
n = GCD(a, b)
i = 2
table = []
while i * i <= n:
	while n % i == 0:
		n = n // i
		table.append(i)
	i += 1
if n > 1:
	table.append(n)
print(len(set(table)) + 1)


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

def gcd(a, b):
	if a % b:
		return gcd(b, a % b)
	else:
		return b
g = gcd(a, b)
(num, ans) = (g, 1)
for i in range(2, int(g ** 0.5) + 1):
	if num % i == 0:
		ans += 1
		while num % i == 0:
			num //= i
if num != 1:
	ans += 1
print(ans)


import fractions
(A, B) = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
	k += 1
	if k ** 2 > GCD:
		cnt += 1
		break
	if GCD % k:
		continue
	cnt += 1
	while GCD % k == 0:
		GCD //= k
print(cnt)


import fractions as fra
(a, b) = map(int, input().split())
c = fra.gcd(a, b)
cnt = 0
for i in range(2, int(c ** 0.5) + 1):
	if c % i == 0:
		cnt += 1
		while True:
			c //= i
			if c % i != 0:
				break
if c != 1:
	cnt += 1
print(cnt + 1)


from fractions import gcd
(A, B) = [int(i) for i in input().split()]
m = gcd(A, B)
pf = []
for i in range(2, m + 1):
	if i ** 2 > m:
		break
	if m % i == 0:
		pf.append(i)
	while m % i == 0:
		m //= i
if m != 1:
	pf.append(m)
print(len(pf) + 1)


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


import math
(A, B) = map(int, input().split())
gcd_ab = math.gcd(A, B)
factors = set()
i = 2
while i <= math.ceil(math.sqrt(gcd_ab)):
	if gcd_ab % i == 0:
		factors.add(i)
		gcd_ab = gcd_ab // i
	else:
		i += 1
factors.add(gcd_ab)
factors.add(1)
print(len(factors))


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

def pr(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
print(len(set(pr(x)) & set(pr(y))) + 1)


from fractions import gcd
(a, b) = map(int, input().split())
g = gcd(a, b)
m = gcd(a, b)
c = 1
i = 2
while i * i <= g:
	if m % i == 0:
		c += 1
	while m % i == 0:
		m = m // i
	i += 1
if m > 1:
	c += 1
print(c)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(a, b) = map(int, input().split())
g = gcd(a, b)
c = 1
for i in range(2, 10 ** 6 + 1):
	if g % i == 0:
		c += 1
		while g % i == 0:
			g //= i
if g != 1:
	c += 1
print(c)


(A, B) = map(int, input().split())
from fractions import gcd
C = gcd(A, B)
num = []
for i in range(2, int(C ** 0.5) + 1):
	while C % i == 0:
		num.append(i)
		C //= i
if C != 1:
	num.append(C)
from collections import Counter
CC = Counter(num)
print(len(CC) + 1)


import fractions
(a, b) = map(int, input().split())
g = fractions.gcd(a, b)
org = g
counter = 1
for i in range(2, int(g ** 0.5) + 1):
	if g % i == 0:
		counter += 1
		g //= i
		while g % i == 0:
			g //= i
if g > int(org ** 0.5):
	counter += 1
print(counter)


from fractions import gcd
from collections import defaultdict
(A, B) = map(int, input().split())
x = gcd(A, B)
d = defaultdict(int)
d[1] = 1
for i in range(2, int(x ** 0.5) + 1):
	while x % i == 0:
		x //= i
		d[i] += 1
if x != 1:
	d[x] += 1
ans = len(d.keys())
print(ans)


import fractions
(A, B) = map(int, input().split())
f = fractions.gcd(A, B)
ans = 1
i = 2
while i ** 2 <= f:
	if f % i == 0:
		ans += 1
	while f % i == 0:
		f = f // i
	i += 1
ans += f > 1
print(ans)


from fractions import gcd
(a, b) = map(int, input().split())
work = gcd(a, b)
count = 1
for i in range(2, int(work ** 0.5) + 1):
	flag = False
	while work % i == 0:
		work //= i
		if not flag:
			count += 1
		flag = True
if work > 2:
	count += 1
print(count)


def gcd(a: int, b: int):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(a, b) = map(int, input().split())
g = gcd(a, b)
ans = set([1])
for i in range(2, 1000000):
	while g % i == 0:
		g = g // i
		ans.add(i)
if g > 1:
	ans.add(g)
print(len(ans))


import fractions
(a, b) = map(int, input().split())
ans = 0
g = fractions.gcd(a, b)
i = 2
table = []
while i * i <= g:
	while g % i == 0:
		g //= i
		table.append(i)
	i += 1
if g > 1:
	table.append(g)
print(len(set(table)) + 1)


from fractions import *
(a, b) = map(int, input().split())
g = gcd(a, b)
l = [g]
for i in range(2, int(g ** 0.5) + 1):
	if g % i < 1:
		l += [i, g // i]
c = 1
for i in sorted(l):
	if g < 2:
		break
	if g % i < 1:
		c += 1
	while g % i < 1:
		g //= i
print(c)


def factor(n):
	factor_set = {1}
	tmp = int(n ** 0.5) + 1
	for i in range(2, tmp):
		while n % i == 0:
			n = n // i
			factor_set.add(i)
	factor_set.add(n)
	return factor_set
(A, B) = map(int, input().split())
print(len(factor(A) & factor(B)))


import bisect, collections, copy, itertools, math, string
import sys

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def S():
	return sys.stdin.readline().rstrip()

def LS():
	return list(sys.stdin.readline().rstrip().split())

def main():

	def prime_factor(n):
		lst = []
		while n % 2 == 0:
			n //= 2
			lst.append(2)
		f = 3
		while f ** 2 <= n:
			if n % f == 0:
				n //= f
				lst.append(f)
			else:
				f += 2
		if n != 1:
			lst.append(n)
		return lst
	(a, b) = LI()
	g = math.gcd(a, b)
	prm = prime_factor(g)
	ans = len(set(prm)) + 1
	print(ans)
main()


import math
ab = [int(i) for i in input().split()]
ab = math.gcd(ab[0], ab[1])
dic = {}
n = 2
while n ** 2 <= ab:
	if ab % n:
		n += 1
	else:
		ab //= n
		dic[n] = dic.get(n, 0) + 1
if 1 < ab:
	dic[ab] = dic.get(ab, 0) + 1
print(len(dic) + 1)


from fractions import gcd
d = gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
	f = False
	while d % i == 0:
		f = True
		d //= i
	if f:
		r += 1
	i += 1
print(r + (d > 1))


from fractions import gcd
from math import sqrt
(A, B) = map(int, input().split())
n = gcd(A, B)
ans = 0
i = 2
while i ** 2 <= n:
	if n % i == 0:
		ans += 1
		while n % i == 0:
			n //= i
	i += 1
if n > 1:
	ans += 1
print(ans + 1)


from fractions import gcd
(A, B) = map(int, input().split())
d = gcd(A, B)
d_ori = d
ans = 1
k = 2
while d > 2:
	plus = 0
	while d % k == 0:
		d //= k
		plus = 1
	ans += plus
	k += 1
	if k > d_ori ** (1 / 2):
		ans += 1
		break
print(ans)


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


(a, b) = map(int, input().split())
f = [1]
while b != 0:
	(a, b) = (b, a % b)
while a % 2 == 0:
	f.append(2)
	a //= 2
p = 3
while p * p <= a:
	if a % p == 0:
		f.append(p)
		a //= p
	else:
		p += 2
if a != 1:
	f.append(a)
print(len(set(f)))


def gcd(a, b):
	return gcd(b, a % b) if b else a
(A, B) = map(int, input().split())
c = gcd(A, B)
d = set()
i = 2
while i * i <= c:
	while c % i == 0:
		c /= i
		d.add(i)
	i += 1
if c != 1:
	d.add(c)
print(len(d) + 1)


import math
(A, B) = map(int, input().split())
gcd = math.gcd(A, B)
ans = [1]
while gcd % 2 == 0:
	ans.append(2)
	gcd = gcd // 2
f = 3
while f * f <= gcd:
	if gcd % f == 0:
		ans.append(f)
		gcd = gcd // f
	else:
		f += 2
if gcd != 1:
	ans.append(gcd)
print(len(set(ans)))


from math import gcd, sqrt, floor
(a, b) = map(int, input().split())
c = gcd(a, b)
x = []
for i in range(1, floor(sqrt(c)) + 1):
	if c % i == 0:
		x.append(i)
		x.append(c // i)
x.sort()
y = []
i = 1
while c > 1 and i < len(x):
	if c % x[i] == 0:
		y.append(x[i])
		c = c // x[i]
	else:
		i += 1
print(len(set(y)) + 1)


from fractions import gcd
(A, B) = map(int, input().split())
p = set([1])
g = gcd(A, B)
for d in range(2, g):
	while g % d == 0:
		p.add(d)
		g //= d
	if d * d >= g:
		break
if g >= 2:
	p.add(g)
print(len(p))


import fractions
(A, B) = map(int, input().split())
C = fractions.gcd(A, B)
primes = []
i = 2
while i * i <= C:
	while C % i == 0:
		C //= i
		primes.append(i)
	i += 1
if C > 1:
	primes.append(C)
print(len(set(primes)) + 1)


import math
(a, b) = map(int, input().split())
x = math.gcd(a, b)
bun = [0] * int(math.sqrt(x) + 1)
bun[1] = 1
for i in range(2, len(bun)):
	while x % i == 0:
		if bun[i] == 0:
			bun[i] += 1
		x = x // i
ans = sum(bun)
if x > 1:
	ans += 1
print(ans)


(a, b) = map(int, input().split())
while b != 0:
	(a, b) = (b, a % b)
pr = set()
i = 2
while i ** 2 <= a:
	while a % i == 0:
		a //= i
		pr.add(i)
	i += 1
pr.add(a)
pr.add(1)
print(len(pr))


import fractions
import collections
(A, B) = map(int, input().split())
p = fractions.gcd(A, B)
num = []
for i in range(2, int(p ** 0.5) + 1):
	while p % i == 0:
		num.append(i)
		p //= i
if p != 1:
	num.append(p)
pp = collections.Counter(num)
print(len(pp) + 1)


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

def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(n ** 0.5) + 1):
		while tmp % i == 0:
			tmp //= i
			arr.append(i)
	if tmp != 1:
		arr.append(tmp)
	if arr == []:
		arr.append(n)
	return list(set(arr))
ans = len(factorization(math.gcd(a, b)))
print(ans + 1 if math.gcd(a, b) != 1 else 1)


import math
(a, b) = map(int, input().split())
gcd = math.gcd(a, b)

def prime_factorization(n):
	i = 2
	prime = []
	if n % i == 0:
		n //= i
		prime.append(2)
		while n % i == 0:
			n //= i
	i += 1
	k = int(n ** 0.5) + 1
	for j in range(i, k + 1, 2):
		if n % j == 0:
			n //= j
			prime.append(j)
			while n % j == 0:
				n //= j
	if n > 1:
		prime.append(n)
	return prime
print(len(prime_factorization(gcd)) + 1)


from fractions import gcd
(A, B) = map(int, input().split())
g = gcd(A, B)
ans = 1
n = 2
while g > 1:
	if n * n > g:
		ans += 1
		break
	if g % n == 0:
		ans += 1
	while g % n == 0:
		g //= n
	n += 1
print(ans)


import math
(A, B) = list(map(int, input().split()))
gcd = math.gcd(A, B)
d = []
if A == 1 or B == 1:
	print(1)
	return
ans = [1]
while gcd % 2 == 0:
	gcd //= 2
	ans.append(2)
i = 3
while i * i <= gcd:
	if gcd % i == 0:
		ans.append(i)
		gcd //= i
	else:
		i += 2
if gcd != 1:
	ans.append(gcd)
print(len(set(ans)))


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

	def primeLst(x):
		acc = []
		f = 2
		while f * f <= x:
			if x % f == 0:
				acc.append(f)
				x //= f
			else:
				f += 1
		if x != 1:
			acc.append(x)
		return acc
	a = set(primeLst(A))
	b = set(primeLst(B))
	if len(a) * len(b) == 0:
		ans = 1
	else:
		ans = len(a & b) + 1
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


import math
from math import gcd, pi, sqrt
INF = float('inf')
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
from collections import Counter, deque

def i_input():
	return int(input())

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

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]

def main():
	(a, b) = i_map()

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

def __starting_point():
	main()
__starting_point()


from fractions import gcd
(a, b) = map(int, input().split())
d = gcd(a, b)
ans = 1
n = d
for i in range(2, d + 1):
	if n % i == 0:
		ans += 1
		while n % i == 0:
			n //= i
	if n < i * i:
		if 1 < n:
			ans += 1
		break
print(ans)


def gcd(a, b):
	if not b:
		return a
	return gcd(b, a % b)
(a, b) = map(int, input().split())
n = gcd(a, b)
i = 2
j = 1
while i * i <= n:
	up = True
	while n % i == 0:
		if up:
			j += 1
			up = False
		n /= i
	i += 1
if n != 1:
	j += 1
print(j)


from math import *
g = gcd(*map(int, input().split()))
D = {}
n = 2
while n * n <= g:
	if g % n:
		n += 1
	else:
		g //= n
		D[n] = D.get(n, 0) + 1
if 1 < g:
	D[g] = D.get(g, 0) + 1
print(len(D) + 1)


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

def fact(x):
	temp = x
	arr = [1]
	for i in range(2, int(math.sqrt(x))):
		if temp % i == 0:
			c = 0
			while temp % i == 0:
				c += 1
				temp //= i
			arr.append(i)
	if temp != 1:
		arr.append(temp)
	if arr == []:
		arr.append(n)
	return arr
a = fact(A)
b = fact(B)
ans = 0
for i in a:
	if i in b:
		ans += 1
print(ans)


from math import sqrt
(a, b) = map(int, input().split())
L = []
if a < b:
	(a, b) = (b, a)
while b != 0:
	r = a % b
	(a, b) = (b, r)
G = a
for i in range(2, int(sqrt(G)) + 1):
	if G % i == 0:
		L.append(i)
		while G % i == 0:
			G /= i
if G != 1:
	L.append(G)
print(len(L) + 1)


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

def factorization(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
s_a = set(factorization(a))
s_b = set(factorization(b))
ans_arr = s_a & s_b
print(len(ans_arr) + 1)


(A, B) = map(int, input().split())
ans = 1
for i in range(2, 1 + int(min(A ** 0.5, B ** 0.5))):
	if A % i == 0 and B % i == 0:
		ans += 1
	while A % i == 0:
		A //= i
	while B % i == 0:
		B //= i
if A != 1 and B != 1 and (A % B == 0 or B % A == 0):
	ans += 1
print(ans)


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

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
print(len(prime_factor(g)) + 1)


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


import math
(n, m) = map(int, input().split())
gcd = math.gcd(m, n)
i = 1
ans = []
max = int(math.sqrt(gcd))
for i in range(2, max + 2):
	while gcd % i == 0:
		ans.append(i)
		gcd //= i
if gcd > 1:
	ans.append(n)
print(len(set(ans)) + 1)


(a, b) = map(int, input().split())
while b > 0:
	(a, b) = (b, a % b)
prime = []
for i in range(2, int(a ** 0.5) + 1):
	if a % i == 0:
		(p, q) = (i, 0)
		while a % i == 0:
			a //= i
			q += 1
		prime.append([p, q])
if a != 1:
	prime.append([a, 1])
print(len(prime) + 1)


(a, b) = map(int, input().split())
while b != 0:
	(a, b) = (b, a % b)
n = a
s = set()
s.add(1)
while n % 2 == 0:
	n //= 2
	s.add(2)
f = 3
while f * f <= n:
	if n % f == 0:
		n //= f
		s.add(f)
	else:
		f += 2
if n != 1:
	s.add(n)
print(len(s))


from fractions import gcd

def factor(n):
	res = []
	for i in range(2, int(n ** 0.5) + 1):
		while n % i == 0:
			res.append(i)
			n //= i
	if n > 1:
		res.append(n)
	return res
(a, b) = map(int, input().split())
c = gcd(a, b)
print(len(set(factor(c))) + 1)


(a, b) = map(int, input().split())
while a > 0:
	(a, b) = (b % a, a)
ret = 1
d = 2
while b >= d * d:
	if b % d == 0:
		ret += 1
		while b % d == 0:
			b //= d
	d += 1
if b > 1:
	ret += 1
print(ret)


from fractions import gcd
(a, b) = map(int, input().split())
gcdab = gcd(a, b)
d = {}
j = 2
while j * j <= gcdab:
	while gcdab % j == 0:
		gcdab //= j
		if j in d:
			d[j] += 1
		else:
			d[j] = 1
	j += 1
if gcdab > 1:
	d[gcdab] = 1
print(len(d) + 1)


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


import fractions
import math
(a, b) = map(int, input().split())
g = fractions.gcd(a, b)
ans = 1
for i in range(2, int(math.sqrt(g)) + 1):
	if g % i == 0:
		ans += 1
		while True:
			g //= i
			if g % i != 0:
				break
if g != 1:
	ans += 1
print(ans)


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

def prime_numbers(N):
	n = N
	res = set()
	for i in range(2, n):
		if i * i >= n:
			break
		if N % i != 0:
			continue
		while N % i == 0:
			N //= i
		res.add(i)
	res.add(N)
	res.add(1)
	return res
a = prime_numbers(A)
b = prime_numbers(B)
ans = len(a.intersection(b))
print(ans)


from math import sqrt
from math import ceil

def prime_factorization(n):
	pfs = [1]
	i = 2
	for i in range(2, int(ceil(sqrt(n)))):
		while n % i == 0:
			pfs.append(i)
			n //= i
	if n > 0:
		pfs.append(n)
	return pfs
(a, b) = map(int, input().split())

def bit_search(pfs):
	m = len(pfs)
	ds = set([])
	for i in range(1 << m):
		d = 1
		for j in range(m):
			if i & 1 << m > 0:
				d *= pfs[m]
		ds.add(d)
	return ds

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
gcdab = gcd(a, b)
pfsab = prime_factorization(gcdab)
pfsabset = set(pfsab)
print(len(pfsabset))


import math

def using_sqrt(k):
	factor = 0
	if k % 2 == 0 and k != 2:
		return False
	for divisor in range(2, math.floor(math.sqrt(k)) + 1):
		if k % divisor == 0:
			factor += 1
	if factor == 0:
		return True
	else:
		return False

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 make_codivisors(n):
	divisors = []
	n0divisors = make_divisors(n[0])
	n0len = len(n0divisors)
	for i in n0divisors:
		for j in range(1, len(n)):
			if n[j] % i != 0:
				break
			if j == len(n) - 1:
				divisors.append(i)
	return divisors
(a, b) = map(int, input().split())
div = make_codivisors([a, b])
ans = 0
for i in div:
	if i == 1:
		ans += 1
	elif using_sqrt(i):
		ans += 1
print(ans)


from fractions import gcd
(A, B) = map(int, input().split())
M = gcd(A, B)
primes = {}
i = 2
while M >= i ** 2:
	if M % i == 0:
		primes[i] = primes.get(i, 0) + 1
		M //= i
	else:
		i += 2 - (i + 1) % 2
if M > 1:
	primes[M] = 1
print(len(primes) + 1)


import math

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())
Af = factorization(A)
Bf = factorization(B)
As = set()
Bs = set()
for i in range(len(Af)):
	As.add(Af[i][0])
for j in range(len(Bf)):
	Bs.add(Bf[j][0])
if A == 1 and B == 1:
	print(1)
else:
	print(len(As & Bs) + 1)


from math import gcd
(a, b) = map(int, input().split())
x = gcd(a, b)
cnt = 1
for i in range(2, int(x ** 0.5) + 1):
	if x == 1:
		break
	if x % i == 0:
		cnt += 1
		while x % i == 0:
			x //= i
else:
	if x != 1:
		cnt += 1
print(cnt)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(a, b) = map(int, input().split())
x = gcd(a, b)
if x == 1:
	print(1)
	exit()
s = []
i = 2
while i * i <= x:
	if x % i == 0:
		s.append(i)
		x /= i
	else:
		i += 1
s.append(x)
print(len(set(s)) + 1)


import fractions
(a, b) = map(int, input().split())
n = fractions.gcd(a, b)
k = int(n ** 0.5)
cnt = 1
for i in range(2, k + 1):
	if n == 1:
		break
	elif n % i == 0:
		while n % i == 0:
			n //= i
		cnt += 1
if n != 1:
	cnt += 1
print(cnt)


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


from math import gcd
(A, B) = map(int, input().split())
g = gcd(A, B)
plist = []
for i in range(2, int(g ** 0.5) + 1):
	if g % i == 0:
		plist.append(i)
		while g % i == 0:
			g //= i
if g != 1:
	plist.append(g)
print(len(plist) + 1)


from math import gcd
(A, B) = map(int, input().split())
m = gcd(A, B)
num = int(m ** 0.5)
ans = 1
for i in range(2, num + 1):
	if m % i:
		continue
	ans += 1
	while not m % i:
		m /= i
if m > 1:
	ans += 1
print(ans)


(A, B) = map(int, input().split())
from fractions import gcd
g = gcd(A, B)
a = [1]
while g % 2 == 0:
	a.append(2)
	g //= 2
f = 3
while f * f <= g:
	if g % f == 0:
		a.append(f)
		g //= f
	else:
		f += 2
if g != 1:
	a.append(g)
print(len(set(a)))


(a, b) = map(int, input().split())
import math
c = math.gcd(a, b)
c2 = c
l = []
i = 2
while i <= c:
	if c % i == 0:
		c = c // i
		l.append(i)
	else:
		i += 1
	if i * i - 1 > c:
		l.append(c)
		break
print(len(set(l)) + 1)


def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]

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()))
A_yakusu = make_divisors(A)
B_yakusu = make_divisors(B)
yakusu_set = set(A_yakusu) & set(B_yakusu)
yakusu_list = list(yakusu_set)
if max(yakusu_list) != 1:
	print(len(factorization(max(yakusu_list))) + 1)
else:
	print(1)


import math
import fractions
(a, b) = map(int, input().split())
a = fractions.gcd(a, b)
i = 2
ans = 1
while i <= a ** 0.5:
	tmp = a
	while a % i == 0:
		a /= i
	if not a == tmp:
		ans += 1
	i += 1
if a > 1:
	ans += 1
print(ans)


(a, b) = [int(i) for i in input().split()]
l = [1]
if a % 2 == 0:
	l.append(2)
while a % 2 == 0:
	a /= 2
i = 3
while a > i ** 2:
	if a % i == 0:
		l.append(i)
	while a % i == 0:
		a /= i
	i += 2
if a not in l:
	l.append(a)
cnt = 0
for i in l:
	if b % i == 0:
		cnt += 1
print(cnt)


import fractions
(a, b) = map(int, input().split())
n = fractions.gcd(a, b)
i = 1
ass = [1]
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)
print(len(set(ass)))


def gcd(a, b):
	if a == 0:
		return b
	else:
		return gcd(b % a, a)
(A, B) = map(int, input().split())
p = set([1])
g = gcd(A, B)
for d in range(2, g):
	while g % d == 0:
		p.add(d)
		g //= d
	if d * d >= g:
		break
if g >= 2:
	p.add(g)
print(len(p))


(a, b) = map(int, input().split())
t = min(a, b)
t1 = t
s = max(a, b)
c = 1
i = 2
while t > 1 and i <= int(t1 ** 0.5 + 1):
	frag = 0
	while t % i == 0:
		t = t / i
		if frag == 0 and s % i == 0:
			c = c + 1
		frag = 1
	if i == 2:
		i = 3
	else:
		i = i + 2
if s % t == 0 and t > int(t1 ** 0.5 + 1):
	c = c + 1
print(c)


import math

def divisors(x):
	l = [[], []]
	for i in range(1, int(math.sqrt(x)) + 1):
		if x % i == 0:
			if i ** 2 != x:
				l[0].append(i)
				l[1].append(x // i)
			else:
				l[0].append(i)
	return l[0] + l[1][::-1]

def primenumber(x):
	for i in range(2, int(math.sqrt(x)) + 1):
		if x % i == 0:
			return False
	return True
(a, b) = map(int, input().split())
cnt = 0
for i in divisors(math.gcd(a, b)):
	if i == 1:
		cnt += 1
	elif primenumber(i):
		cnt += 1
print(cnt)


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

def prime_factorization(x):
	import math
	re = []
	i = 2
	while x != 1:
		if x % i == 0:
			re.append(i)
			x //= i
		else:
			i += 1
			if i > math.sqrt(x):
				re.append(x)
				break
	return re

def solve(A, B):
	div = gcd(A, B)
	print(len(set(prime_factorization(div))) + 1)

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


import math
(A, B) = [int(x) for x in input().split()]

def prime_factorization(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
C = math.gcd(A, B)
print(len(set(prime_factorization(C))) + 1)


from fractions import *
g = gcd(*map(int, input().split()))
s = {1}
for i in range(2, int(g ** 0.5) + 1):
	while g % i < 1:
		g //= i
		s |= {i}
print(len(s) + (g > 1))


import math
(A, B) = [int(_) for _ in input().split()]
N = math.gcd(A, B)
ans = 1
for i in range(2, int(math.sqrt(N) + 1) + 1):
	if N % i == 0:
		ans += 1
		while N % i == 0:
			N //= i
if N > 1:
	ans += 1
print(ans)


import fractions, math
(a, b) = map(int, input().split())
gcd = fractions.gcd(a, b)
n = 2
cnt = 1
sq = math.sqrt(gcd)
while n <= sq:
	if gcd % n == 0:
		cnt += 1
		while gcd % n == 0:
			gcd = gcd // n
	n += 1
if gcd != 1:
	cnt += 1
print(cnt)


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

def gcd(x, y):
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)
n = gcd(a, b)
i = 2
ans = [1]
while i * i <= n:
	if n % i == 0:
		n /= i
		ans.append(i)
	else:
		i += 1
ans.append(n)
print(len(set(ans)))


from math import sqrt
from fractions import gcd
(A, B) = map(int, input().split())
ans = 1
g = gcd(A, B)
for i in range(2, 1 + int(sqrt(g))):
	if g % i == 0:
		ans += 1
		while g % i == 0:
			g //= i
if g != 1:
	ans += 1
print(ans)


def division(n):
	if n < 2:
		return [1]
	prime_factors = [1]
	for i in range(2, int(n ** 0.5) + 1):
		while n % i == 0:
			prime_factors.append(i)
			n //= i
	if n > 1:
		prime_factors.append(n)
	return prime_factors
(a, b) = map(int, input().split())
da = set(division(a))
db = set(division(b))
cnt = 0
for i in da:
	if i in db:
		cnt += 1
print(cnt)


(A, B) = map(int, input().split())
C = []
D = []

def prime_factor(n):
	E = []
	for i in range(2, int(n ** 0.5) + 1):
		while n % i == 0:
			E.append(i)
			n = n // i
	if n != 1:
		E.append(n)
	return E
C = prime_factor(A)
D = prime_factor(B)
f = set(C) & set(D)
print(len(f) + 1)