import math
t = 1
# t = input()
# t = int(t)
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	a,b = map(int,input().strip().split())
	j = 1
	ma = {}
	mb = {}
	if a%2 == 0:
		ma[2] = 1
		while a%2 == 0:
			a /= 2
	p = math.sqrt(a) + 1
	p = int(p)
	for i in range(3,p,2):
		if a%i == 0:
			ma[i] = 1
			while a%i == 0:
				a /= i
	if a > 2:
		ma[a] = 1
	if b%2 == 0:
		mb[2] = 1
		while b%2 == 0:
			b /= 2
	p = math.sqrt(b) + 1
	p = int(p)
	for i in range(3,p,2):
		if b%i == 0:
			mb[i] = 1
			while b%i == 0:
				b /= i
	if b > 2:
		mb[b] = 1
	ans = 1
	for x,y in ma.items():
		if x in mb:
			ans += 1
	print(ans) import math math t = 1 t 1 def max(a,b):
	if a > b:
		return a
	return b max if a > b:
		return a
	 a > b a b return a a return b b a a b b while t > 0:
	t -= 1
	a,b = map(int,input().strip().split())
	j = 1
	ma = {}
	mb = {}
	if a%2 == 0:
		ma[2] = 1
		while a%2 == 0:
			a /= 2
	p = math.sqrt(a) + 1
	p = int(p)
	for i in range(3,p,2):
		if a%i == 0:
			ma[i] = 1
			while a%i == 0:
				a /= i
	if a > 2:
		ma[a] = 1
	if b%2 == 0:
		mb[2] = 1
		while b%2 == 0:
			b /= 2
	p = math.sqrt(b) + 1
	p = int(p)
	for i in range(3,p,2):
		if b%i == 0:
			mb[i] = 1
			while b%i == 0:
				b /= i
	if b > 2:
		mb[b] = 1
	ans = 1
	for x,y in ma.items():
		if x in mb:
			ans += 1
	print(ans) t > 0 t 0 t -= 1 t 1 a,b = map(int,input().strip().split()) a map(int,input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split b j = 1 j 1 ma = {} ma {} mb = {} mb {} if a%2 == 0:
		ma[2] = 1
		while a%2 == 0:
			a /= 2
	 a%2 == 0 a%2 a 2 0 ma[2] = 1 ma[2] ma 2 1 while a%2 == 0:
			a /= 2
	 a%2 == 0 a%2 a 2 0 a /= 2 a 2 p = math.sqrt(a) + 1 p math.sqrt(a) + 1 math.sqrt(a) math.sqrt math sqrt a 1 p = int(p) p int(p) int p for i in range(3,p,2):
		if a%i == 0:
			ma[i] = 1
			while a%i == 0:
				a /= i
	 i range(3,p,2) range 3 p 2 if a%i == 0:
			ma[i] = 1
			while a%i == 0:
				a /= i
	 a%i == 0 a%i a i 0 ma[i] = 1 ma[i] ma i 1 while a%i == 0:
				a /= i
	 a%i == 0 a%i a i 0 a /= i a i if a > 2:
		ma[a] = 1
	 a > 2 a 2 ma[a] = 1 ma[a] ma a 1 if b%2 == 0:
		mb[2] = 1
		while b%2 == 0:
			b /= 2
	 b%2 == 0 b%2 b 2 0 mb[2] = 1 mb[2] mb 2 1 while b%2 == 0:
			b /= 2
	 b%2 == 0 b%2 b 2 0 b /= 2 b 2 p = math.sqrt(b) + 1 p math.sqrt(b) + 1 math.sqrt(b) math.sqrt math sqrt b 1 p = int(p) p int(p) int p for i in range(3,p,2):
		if b%i == 0:
			mb[i] = 1
			while b%i == 0:
				b /= i
	 i range(3,p,2) range 3 p 2 if b%i == 0:
			mb[i] = 1
			while b%i == 0:
				b /= i
	 b%i == 0 b%i b i 0 mb[i] = 1 mb[i] mb i 1 while b%i == 0:
				b /= i
	 b%i == 0 b%i b i 0 b /= i b i if b > 2:
		mb[b] = 1
	 b > 2 b 2 mb[b] = 1 mb[b] mb b 1 ans = 1 ans 1 for x,y in ma.items():
		if x in mb:
			ans += 1
	 x y ma.items() ma.items ma items if x in mb:
			ans += 1
	 x in mb x mb ans += 1 ans 1 print(ans) print ans ans += 1 1 ans a /= 2 2 a p = int(p) int(p) p a /= i i a ans = 1 1 ans p = math.sqrt(a) + 1 math.sqrt(a) + 1 p b /= 2 2 b p = int(p) int(p) p a,b = map(int,input().strip().split()) map(int,input().strip().split()) a b /= i i b t -= 1 1 t b = map(int,input().strip().split()) map(int,input().strip().split()) b p = math.sqrt(b) + 1 math.sqrt(b) + 1 p t = 1 1 t j = 1 1 j def max(a,b):
	if a > b:
		return a
	return b def max(a,b):
	if a > b:
		return a
	return b max ma = {} {} ma mb = {} {} mb
import math
t = 1
# t = input()
# t = int(t)
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	a,b = map(int,input().strip().split())
	j = 1
	ma = {}
	mb = {}
	if a%2 == 0:
		ma[2] = 1
		while a%2 == 0:
			a /= 2
	p = math.sqrt(a) + 1
	p = int(p)
	for i in range(3,p,2):
		if a%i == 0:
			ma[i] = 1
			while a%i == 0:
				a /= i
	if a > 2:
		ma[a] = 1
	if b%2 == 0:
		mb[2] = 1
		while b%2 == 0:
			b /= 2
	p = math.sqrt(b) + 1
	p = int(p)
	for i in range(3,p,2):
		if b%i == 0:
			mb[i] = 1
			while b%i == 0:
				b /= i
	if b > 2:
		mb[b] = 1
	ans = 1
	for x,y in ma.items():
		if x in mb:
			ans += 1
	print(ans)
