Description
In a particular language words are written using only two symbols: ones(1) and zeroes(0). A given word N is called “good” if it can be written in the form of concatenation of several(two or more than two) copies of some shorter word, and is called bad otherwise. 

For example the words 100, 1100, 0010 are “bad”, while the words 0101, 001001 are “good”.

The task is to calculate the number T of good words which can be formed using exactly a ones and b zeroes.

Report your answer as T modulo 10^7+1

Input Format
First line contains the number of zeroes
Seconds line contains the number of ones

Output Format
One line containing the maximum number of "good" words that can be formed taken modulo 10^7+1

Input Limits
0 ≤ a, b ≤ 5000

SAMPLE INPUT
2
4

SAMPLE OUTPUT
3

Explanation

The good words and their corresponding shorter word, that can be formed using 2 zeroes and 4 ones are
011011  -  011
101101  -  101
110110  -  110
dc = dict()

def desfac(n):
	for i in range(2,n):
		if n%i == 0:
			dc[i] = 0

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

def fac(a):
	s = 1
	for i in range(2,a+1):
		s *= i
	return s

zer = int(input())
one = int(input())
md = 10**7+1
span = zer+one
ans = 0

for i in range(1, span+1): # all allowed
	dc[i] = 1

for i in range(span-1, 0, -1):
	if span%i == 0 and dc[i] == 1:
		divs = int(span/i)
		if zer%divs == 0 and one%divs == 0:
			zc = int(zer / divs)
			oc = int(one / divs)
			if zc+oc == i:
				ans += int(fac(i) / (fac(zc) * fac(oc)))
				desfac(i)
ans %= md

if ans>1:
	if zer==0 or one==0:
		ans = 1

print(ans)