dp = [[0 for i in xrange(5005)] for i in xrange(5005)]
def f_f(c,t):
if (dp[c][t] != 0):
return dp[c][t] - 1;
if (t==1):
return 1;
ret = 0
i = int(c/t)
while(i >= 0):
ret=ret+ f_f (c-i*t, t-1)
if ret >= 1988:
ret %= 1988
i = i - 1
dp[c][t] = 1 + ret
return dp[c][t] - 1
while(1):
o = raw_input();
s = map(int,o.split())
a = s[0]
b = s[1]
if (a == 0 and b == 0):
break
print f_f(a-b,b)