N = 2000 def f(S): pre0 = [0] * N pre1 = [0] * N pre0[0] = 1 for s in S: dp0 = [0] * N dp1 = [0] * N for i in range(N): for j in range(10): if j == s: if i - j >= 0: dp0[i] += pre0[i - j] elif j < s: if i - j >= 0: dp1[i] += pre0[i - j] if i - j >= 0: dp1[i] += pre1[i - j] dp0, pre0 = pre0, dp0 dp1, pre1 = pre1, dp1 L = [0] * N for i in range(N): L[i] = pre0[i] + pre1[i] return L M, D = input().split() M = [int(m) for m in M] D = [int(d) for d in D] ans = -1 mod = 10**9 + 9 A, B = f(M), f(D) for i in range(N): ans += A[i] * B[i] ans %= mod print(ans%mod)