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) import math math A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B 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 fact temp = x temp x arr = [1] arr [1] 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)
	 i range(2, int(math.sqrt(x))) range 2 int(math.sqrt(x)) int math.sqrt(x) math.sqrt math sqrt x if temp % i == 0:
			c = 0
			while temp % i == 0:
				c += 1
				temp //= i
			arr.append(i)
	 temp % i == 0 temp % i temp i 0 c = 0 c 0 while temp % i == 0:
				c += 1
				temp //= i
			 temp % i == 0 temp % i temp i 0 c += 1 c 1 temp //= i temp i arr.append(i) arr.append arr append i if temp != 1:
		arr.append(temp)
	 temp != 1 temp 1 arr.append(temp) arr.append arr append temp if arr == []:
		arr.append(n)
	 arr == [] arr [] arr.append(n) arr.append arr append n return arr arr x x a = fact(A) a fact(A) fact A b = fact(B) b fact(B) fact B ans = 0 ans 0 for i in a:
	if i in b:
		ans += 1 i a if i in b:
		ans += 1 i in b i b ans += 1 ans 1 print(ans) print ans ans = 0 0 ans B = map(int, input().split()) map(int, input().split()) B 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 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 fact b = fact(B) fact(B) b ans += 1 1 ans a = fact(A) fact(A) a A, B = map(int, input().split()) map(int, input().split()) A
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)