You are given a range of integers from 1 to K (inclusive) and a value D. Find the count of integers in the range whose digit sum in base ten is a multiple of D, modulo 10^9 + 7. Input is provided in the format: K, D. Output the count of such integers. All input values are integers. Constraints: 1 ≤ K < 10^10000, 1 ≤ D ≤ 100. Example: For input 30, 4, the output is 6, representing the count of integers (4, 8, 13, 17, 22, 26) with digit sum multiples of 4.

# Buggy version:
d = int(input())
n = input()
t = len(n)
mod = 10**9 + 7
dp1 = [[0 for i in range(d)] for j in range(t)]
dp2 = [[0 for i in range(d)] for j in range(t)]

dp1[0][int(n[0])%d] += 1
for i in range(int(n[0])):
    dp2[0][i%d] += 1
    
for i in range(1,t):
    now = int(n[i])
    for j in range(10):
        if j == now:
            for k in range(d):
                dp1[i][(k+j)%d] += dp1[i-1][k]
                dp2[i][(k+j)%d] += dp2[i-1][k]
                dp1[i][(k+j)%d] %= mod
                dp2[i][(k+j)%d] %= mod
        elif j < now:
            for k in range(d):
                dp2[i][(k+j)%d] += dp1[i-1][k]
                dp2[i][(k+j)%d] += dp2[i-1][k]
                dp2[i][(k+j)%d] %= mod
        else:
            for k in range(d):
                dp2[i][(k+j)%d] += dp2[i-1][k]
                dp2[i][(k+j)%d] %= mod

print((dp1[-1][0]+dp2[-1][0]-1)%mod)

# Fixed version:
n = input()
d = int(input())
t = len(n)
mod = 10**9 + 7
dp1 = [[0 for i in range(d)] for j in range(t)]
dp2 = [[0 for i in range(d)] for j in range(t)]

dp1[0][int(n[0])%d] += 1
for i in range(int(n[0])):
    dp2[0][i%d] += 1
    
for i in range(1,t):
    now = int(n[i])
    for j in range(10):
        if j == now:
            for k in range(d):
                dp1[i][(k+j)%d] += dp1[i-1][k]
                dp2[i][(k+j)%d] += dp2[i-1][k]
                dp1[i][(k+j)%d] %= mod
                dp2[i][(k+j)%d] %= mod
        elif j < now:
            for k in range(d):
                dp2[i][(k+j)%d] += dp1[i-1][k]
                dp2[i][(k+j)%d] += dp2[i-1][k]
                dp2[i][(k+j)%d] %= mod
        else:
            for k in range(d):
                dp2[i][(k+j)%d] += dp2[i-1][k]
                dp2[i][(k+j)%d] %= mod

print((dp1[-1][0]+dp2[-1][0]-1)%mod)

# Buggy version:
import sys
input = sys.stdin.readline


def main():
    K = input().replace("\n", "")
    D = int(input())
    
    mod = pow(10, 9)+7
    n = len(K)
    dp = [[0]*D for _ in range(n+1)]
    
    dp[0][0] = 1
    sub = 0
    
    if D == 1:
        ans = 0
        for i in range(n):
            ans = (ans*10+int(K[i]))%mod
        print(ans)
        sys.exit()
    
    for i in range(n):
        if i != 0:
            for j in range(10):
                for k in range(D):
                    dp[i+1][(k+j)%D] += dp[i][k]
                    dp[i+1][(k+j)%D] %= mod
            for j in range(1, 10):
                dp[i+1][j%D] += 1
                dp[i+1][j%D] %= mod
        
        
        for j in range(int(K[i])):
            if i == 0 and j == 0:
                continue
            dp[i+1][(j+sub)%D] += 1
            dp[i+1][(j+sub)%D] %= mod
        sub = (sub+int(K[i]))%D
    print(dp)
    print(dp[n][0])
    
    
if __name__ == "__main__":
    main()


# Fixed version:
import sys
input = sys.stdin.readline


def main():
    K = input().replace("\n", "")
    D = int(input())
    
    mod = pow(10, 9)+7
    n = len(K)
    dp = [[0]*D for _ in range(n+1)]
    
    dp[0][0] = 1
    sub = 0
    
    if D == 1:
        ans = 0
        for i in range(n):
            ans = (ans*10+int(K[i]))%mod
        print(ans)
        sys.exit()


    for i in range(n):
        if i != 0:
            for j in range(10):
                for k in range(D):
                    dp[i+1][(k+j)%D] += dp[i][k]
                    dp[i+1][(k+j)%D] %= mod
            for j in range(1, 10):
                dp[i+1][j%D] += 1
                dp[i+1][j%D] %= mod
        
        
        for j in range(int(K[i])):
            if i == 0 and j == 0:
                continue
            dp[i+1][(j+sub)%D] += 1
            dp[i+1][(j+sub)%D] %= mod
        sub = (sub+int(K[i]))%D
    
    sub = 0
    for i in range(n):
        sub = (sub+int(K[i]))%D
    if sub == 0:
        dp[n][0] += 1
        dp[n][0] %= mod
        
    
    print(dp[n][0])
    
    
if __name__ == "__main__":
    main()

# Buggy version:
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7

def main():
    K = input()
    D = int(input())

    dp = [[[0]*2 for _ in range(D)] for _ in range(len(K) + 1)] 
    dp[0][0][0] = 1
    for i in range(len(K)):
        M = int(K[i])
        for j in range(D):
            for k in range(10):
                if k < M:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1] + dp[i][j][0]
                elif k == M:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1]
                    dp[i + 1][(j + k)%D][0] += dp[i][j][0]
                #else:
                    #dp[i + 1][(j + k)%D][1] += dp[i][j][1]
                dp[i + 1][(j + k)%D][0] %= MOD
                dp[i + 1][(j + k)%D][1] %= MOD
    ans = sum(dp[-1][0])
    print((ans - 1)%MOD)       
if __name__ == '__main__':
    main()
    


# Fixed version:
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7

def main():
    K = input()
    D = int(input())

    dp = [[[0]*2 for _ in range(D)] for _ in range(len(K) + 1)] 
    dp[0][0][0] = 1
    for i in range(len(K)):
        M = int(K[i])
        for j in range(D):
            for k in range(10):
                if k < M:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1] + dp[i][j][0]
                elif k == M:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1]
                    dp[i + 1][(j + k)%D][0] += dp[i][j][0]
                else:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1]
                dp[i + 1][(j + k)%D][0] %= MOD
                dp[i + 1][(j + k)%D][1] %= MOD
    ans = sum(dp[-1][0])
    print((ans - 1)%MOD)       
if __name__ == '__main__':
    main()

# Buggy version:
n = int(input())
d = int(input())
p = 10**9+7
if d == 1:
    print(n % d)
    exit()
N = [int(i) for i in list(str(n))]
DP0 = [0] * d
DP1 = [0] * d
DP1[0] += 1
for i in N:
    DP0_ = [0] * d
    DP1_ = [0] * d
    for r in range(d):
        for j in range(i):
            DP0_[r] += DP1[(r-j) % d]
        for j in range(i, 10):
            DP0_[r] += DP0[(r-j) % d]
        for j in range(i+1):
            DP1_[r] += DP1[(r-j) % d]
        for j in range(i+1, 10):
            DP1_[r] += DP0[(r-j) % d]
        DP0_[r], DP1_[r] = DP0_[r] % p, DP1_[r] % p
    DP0, DP1 = DP0_, DP1_
print(DP1[0]-1)


# Fixed version:
n = int(input())
d = int(input())
p = 10**9+7
if d == 1:
    print(n % p)
    exit()
N = [int(i) for i in list(str(n))]
DP0 = [0] * d
DP1 = [0] * d
DP1[0] += 1
for i in N:
    DP0_ = [0] * d
    DP1_ = [0] * d
    for r in range(d):
        for j in range(i):
            DP0_[r] += DP1[(r-j) % d]
            DP1_[r] += DP1[(r-j) % d]
        DP0_[r] += DP0[(r-i) % d]
        DP1_[r] += DP1[(r-i) % d]
        for j in range(i+1, 10):
            DP0_[r] += DP0[(r-j) % d]
            DP1_[r] += DP0[(r-j) % d]
        DP0_[r], DP1_[r] = DP0_[r] % p, DP1_[r] % p
    DP0, DP1 = DP0_, DP1_
print((DP1[0]-1) % p)

# Buggy version:
s,d=int(input()),input()
n=[int(i) for i in s]
l=len(s)
mod=10**9+7
dp=[[[0]*d,[0]*d] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for j in range(d):
            for x in range(10 if smaller else n[i]+1):
                dp[i+1][smaller or x<n[i]][(j+x)%d] += dp[i][smaller][j]
                dp[i+1][smaller or x<n[i]][(j+x)%d]%=mod
print((dp[l][0][0]+dp[l][1][0]-1)%mod)

# Fixed version:
s,d=input(),int(input())
n=[int(i) for i in s]
l=len(s)
mod=10**9+7
dp=[[[0]*d,[0]*d] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for j in range(d):
            for x in range(10 if smaller else n[i]+1):
                dp[i+1][smaller or x<n[i]][(j+x)%d] += dp[i][smaller][j]
                dp[i+1][smaller or x<n[i]][(j+x)%d]%=mod
print((dp[l][0][0]+dp[l][1][0]-1)%mod)

# Buggy version:
K=input()
D=int(input())
#余り0,余り1,余り2,…,余り(D-1)
dp=[0]*D
mod=10**9+7
s=0
for i in range(len(K)):
  ndp=[0]*D
  #余りがjだったものは(j+d)%Dの余りに変わるので
  for j in range(D):
    for d in range(10):
      ndp[(j+d)%D]=(ndp[(j+d)%D]+dp[j])%mod
  #直前までKと数字が同じだったものをカウント
  for d in range(int(K[i])):
    ndp[(s+d)%D]+=1 
  dp=ndp
  s=(s+int(K[i]))%D
print((dp[0]-1)%mod)

# Fixed version:
K=input()
D=int(input())
#余り0,余り1,余り2,…,余り(D-1)
dp=[0]*D
mod=10**9+7
s=0
for i in range(len(K)):
  ndp=[0]*D
  #余りがjだったものは(j+d)%Dの余りに変わるので
  for j in range(D):
    for d in range(10):
      ndp[(j+d)%D]=(ndp[(j+d)%D]+dp[j])%mod
  #直前までKと数字が同じだったものをカウント
  for d in range(int(K[i])):
    ndp[(s+d)%D]+=1 
  dp=ndp
  s=(s+int(K[i]))%D
print((dp[0]-1+(s==0))%mod)

# Buggy version:
k = str(input())
d = int(input())

l = len(k)

mod = 10 ** 9 + 7

#less than: 1, else: 0
dp = [[[0] * 2 for _ in range(d)] for i in range(l+1)]
dp[0][0][0] = 1

for i in range(l):
    for j in range(d):
        for num in range(10):
            dp[i+1][(j+num) % d][1] = (dp[i+1][(j+num) % d][1] + dp[i][j][1]) % mod
        for num in range(int(k[i])):
            dp[i+1][(j+num) % d][1] = (dp[i+1][(j+num) % d][1] + dp[i][j][0]) % mod
            dp[i+1][(j+num) % d][0] = (dp[i+1][(j+num) % d][0] + dp[i][j][0]) % mod
                
ans = (dp[l][0][0] + dp[l][0][1] + mod - 1) % mod

print(ans)

# Fixed version:
k = str(input())
d = int(input())
 
l = len(k)
 
mod = 10 ** 9 + 7
 
#less than: 1, else: 0
dp = [[[0] * 2 for _ in range(d)] for i in range(l+1)]
dp[0][0][0] = 1
 
for i in range(l):
    lim = int(k[i])
    for j in range(d):
        for num in range(10):
            dp[i+1][(j+num) % d][1] = (dp[i+1][(j+num) % d][1] + dp[i][j][1]) % mod
        for num in range(lim):
            dp[i+1][(j+num) % d][1] = (dp[i+1][(j+num) % d][1] + dp[i][j][0]) % mod
        
        dp[i+1][(j+lim) % d][0] = (dp[i+1][(j+lim) % d][0] + dp[i][j][0]) % mod
                
ans = (dp[l][0][0] + dp[l][0][1] + mod - 1) % mod
 
print(ans)

# Buggy version:
k = input()
d = int(input())

MOD = 10**9 + 7

k_len = len(k)
dp = [[0] * d for _ in range(k_len-1)]

if( k_len == 1 ):
    k = int(k)
    print(k//d)
    exit()

for i in range(10):
    dp[0][i%d] += 1

for i in range(1, k_len-1):
    for j in range(10):
        dp[i][0] += dp[i-1][(0-j)%d]
    dp[i][0] = dp[i][0] % MOD
    for j in range(1,d):
        dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][(j-10)%d]) % MOD

ans = 0
heads = 0
for i in range(k_len-1):
    pick = int(k[i])
    for j in range(pick):
        ans += dp[k_len - 2 - i][(0 - j - heads) % d]
        ans = ans % MOD
    heads += pick

print(ans - 1)


# Fixed version:
k = input()
d = int(input())

MOD = 10**9 + 7

k_len = len(k)
dp = [[0] * d for _ in range(k_len)]
dp[0][0] = 1

# if( k_len == 1 ):
#     k = int(k)
#     print(k//d)
#     exit()
#
# for i in range(10):
#     dp[0][i%d] += 1

for i in range(1, k_len):
    for j in range(10):
        dp[i][0] += dp[i-1][(0-j)%d]
    dp[i][0] = dp[i][0] % MOD
    for j in range(1,d):
        dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][(j-10)%d]) % MOD

ans = 0
heads = 0
for i in range(k_len):
    pick = int(k[i])
    for j in range(pick):
        ans += dp[k_len - 1 - i][(0 - j - heads) % d]
        ans = ans % MOD
    heads += pick

if(heads % d == 0):
    ans += 1

print((ans - 1)%MOD)

# Buggy version:
K = input()
N = len(K)
D = int(input())
Y = [0] * D
P = 10**9+7
a = 0
for i in range(N):
    nY = [0] * D
    c = int(K[i])
    for j in range(10):
        for k in range(D):
            nk = (j+k)%D
            nY[nk] += Y[k]
        if j < c:
            nk = (j+a)%D
            nY[nk] = (nY[nk] + 1) % P
    
    a = (a+c) % D
    Y = nY
print((Y[0] - 1) % P)


# Fixed version:
K = input()
N = len(K)
D = int(input())
Y = [0] * D
P = 10**9+7
a = 0
for i in range(N):
    nY = [0] * D
    c = int(K[i])
    for j in range(10):
        if j < c:
            nk = (j+a) % D
            nY[nk] = (nY[nk] + 1) % P

        for k in range(D):
            nk = (j+k) % D
            nY[nk] = (nY[nk] + Y[k]) % P
        
    a = (a+c) % D
    Y = nY
print((Y[0] - 1 + (a==0)) % P)

# Buggy version:
k = int(input())
d = int(input())

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = dp1.copy()

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] = 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] = (dp1[(l+j)%d]+dp2[l])%mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] = (dp1[(mm1+j)%d]+1)%mod
    print(dp1)
    

    mm1 = (mm1+li[i])%d
    dp2 = dp1.copy()
    dp1 = [0 for _ in range(d)]


print((dp2[0]-1)%mod)   








# Fixed version:
k = int(input())
d = int(input())

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = [0 for _ in range(d)]

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] += 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] += dp2[l]
            dp1[(l+j)%d] %= mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] += 1
            dp1[(mm1+j)%d] %= mod
    #print(dp1,dp2)
    mm1 = (mm1+li[i])%d
    dp2 = [dp1[i] for i in range(d)]
    dp1 = [0 for _ in range(d)]
dp2[sum(li)%d]+=1
print((dp2[0]-1)%mod)

# Buggy version:
K = input()
n = len(K)
D = int(input())
dp = [[[0]*2 for i in range(D)] for _ in range(n)]
for i in range(int(K[0])):
    dp[0][i%D][0] += 1
dp[0][int(K[0])%D][1] += 1
for i in range(n-1):
    for j in range(D):
        for d in range(10):
            dp[i+1][(j+d)%D][0]+=dp[i][j][0]
            dp[i+1][(j+d)%D][0]%=mod
        for d in range(int(K[i+1])):
            dp[i+1][(j+d)%D][0]+=dp[i][j][1]
            dp[i+1][(j+d)%D][0]%=mod
        dp[i+1][(j+int(K[i+1]))%D][1] += dp[i][j][1]
        dp[i+1][(j+int(K[i+1]))%D][1]%=mod


print(dp[-1][0][0]+dp[-1][0][1]-1)




# Fixed version:
mod = 10**9+7
K = input()
n = len(K)
D = int(input())
dp = [[[0]*2 for i in range(D)] for _ in range(n)]
for i in range(int(K[0])):
    dp[0][i%D][0] += 1
dp[0][int(K[0])%D][1] += 1
for i in range(n-1):
    for j in range(D):
        for d in range(10):
            dp[i+1][(j+d)%D][0]+=dp[i][j][0]
            dp[i+1][(j+d)%D][0]%=mod
        for d in range(int(K[i+1])):
            dp[i+1][(j+d)%D][0]+=dp[i][j][1]
            dp[i+1][(j+d)%D][0]%=mod
        dp[i+1][(j+int(K[i+1]))%D][1] += dp[i][j][1]
        dp[i+1][(j+int(K[i+1]))%D][1]%=mod
print((dp[-1][0][0]+dp[-1][0][1]-1)%mod)

# Buggy version:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.buffer.readline().rstrip()
def resolve():
    k=input()
    d=int(input())
    n=len(k)
    dp=[[[0]*2 for _ in range(d)] for _ in range(n+1)]
    dp[0][0][0]=1
    for i in range(n):
        a=int(k[i])
        for j in range(d):
            for o in range(10):
                dp[i+1][(j+o)%d][1]+=dp[i][j][1]
                dp[i+1][(j+o)%d][1]%=MOD
                if(o<a):
                    dp[i+1][(j+o)%d][1]+=dp[i][j][0]
                    dp[i+1][(j+o)%d][1]%=MOD
                elif(o==a):
                    dp[i+1][(j+o)%d][0]+=dp[i][j][0]
                    dp[i+1][(j+o)%d][0]%=MOD
    print((dp[n][0][0]+dp[n][0][1]-1)%MOD)
resolve()

# Fixed version:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    k=input()
    d=int(input())
    n=len(k)
    dp=[[[0]*2 for _ in range(d)] for _ in range(n+1)]
    dp[0][0][0]=1
    for i in range(n):
        a=int(k[i])
        for j in range(d):
            for o in range(10):
                dp[i+1][(j+o)%d][1]+=dp[i][j][1]
                dp[i+1][(j+o)%d][1]%=MOD
                if(o<a):
                    dp[i+1][(j+o)%d][1]+=dp[i][j][0]
                    dp[i+1][(j+o)%d][1]%=MOD
                elif(o==a):
                    dp[i+1][(j+o)%d][0]+=dp[i][j][0]
                    dp[i+1][(j+o)%d][0]%=MOD
    print((dp[n][0][0]+dp[n][0][1]-1)%MOD)
resolve()

# Buggy version:
K = input()
D = int(input())
N = len(K)
dp = [[0] * D for i in range(N)]
for i in range(int(K[0])):
    dp[0][i%D] += 1
tight = int(K[0])%D
for i in range(1, N):
    for j in range(D):
        for k in range(10):
            dp[i][j] += dp[i-1][(j-k)%D]
            dp[i][j] %= mod
    for k in range(int(K[i])):
        dp[i][(tight+k)%D] += 1
    tight = (tight+int(K[i]))%D
print((dp[N-1][0]+(tight==0)-1)%mod)

# Fixed version:
mod = 10**9+7
K = input()
D = int(input())
N = len(K)
dp = [[0] * D for i in range(N)]
for i in range(int(K[0])):
    dp[0][i%D] += 1
tight = int(K[0])%D
for i in range(1, N):
    for j in range(D):
        for k in range(10):
            dp[i][j] += dp[i-1][(j-k)%D]
            dp[i][j] %= mod
    for k in range(int(K[i])):
        dp[i][(tight+k)%D] += 1
    tight = (tight+int(K[i]))%D
print((dp[N-1][0]+(tight==0)-1)%mod)

# Buggy version:
k = input()
d = int(input())
mod = 10**9 + 7

dp = [[[0] * d for i in range(2)] for j in range(len(k)+1)]
dp[0][0][0] = 1

for i in range(len(k)):
    for j in range(2):
        for m in range(d):
            if j == 1:
                for num in range(10):
                    dp[i+1][j][(m+num)%d] += dp[i][j][m]
                    dp[i+1][j][(m+num)%d] %= mod
            else:
                for num in range(int(k[i])+1):
                    if num != int(k[i]):
                        dp[i+1][1][(m+num)%d] += dp[i+1][j][m]
                        dp[i+1][1][(m+num)%d] %= mod
                    else:
                        dp[i+1][0][(m+num)%d] += dp[i+1][j][m]
                        dp[i + 1][0][(m + num) % d] %= mod

print((dp[len(k)][0][0] + dp[len(k)][1][0] - 1) % mod)


# Fixed version:
k = input()
d = int(input())
mod = 10**9 + 7

dp = [[[0] * d for i in range(2)] for j in range(len(k)+1)]
dp[0][0][0] = 1

for i in range(len(k)):
    for j in range(2):
        for m in range(d):
            if j == 1:
                for num in range(10):
                    dp[i+1][j][(m+num)%d] += dp[i][j][m]
                    dp[i+1][j][(m+num)%d] %= mod
            else:
                for num in range(int(k[i])+1):
                    if num != int(k[i]):
                        dp[i+1][1][(m+num)%d] += dp[i][j][m]
                        dp[i+1][1][(m+num)%d] %= mod
                    else:
                        dp[i+1][0][(m+num)%d] += dp[i][j][m]
                        dp[i + 1][0][(m + num) % d] %= mod

print((dp[len(k)][0][0] + dp[len(k)][1][0] - 1) % mod)

# Buggy version:
K = input()
D = int(input())
L = len(K)
MOD = 10**9+7
dp = [[[0]*D for j in range(2)] for i in range(L+1)] #dp[i][less][modD]
dp[0][0][0] = 1
for i,c in enumerate(K):
    for less in range(2):
        lim = 9 if less else int(c)
        for d in range(lim+1):
            dp[i+1][less or d < lim][(r+d)%D] += dp[i][less][r]
            dp[i+1][less or d < lim][(r+d)%D] %= MOD

print((dp[-1][0][0] + dp[-1][1][0] - 1) % MOD)

# Fixed version:
K = input()
D = int(input())
L = len(K)
MOD = 10**9+7
dp = [[[0]*D for j in range(2)] for i in range(L+1)] #dp[i][less][modD]
dp[0][0][0] = 1
for i,c in enumerate(K):
    for less in range(2):
        lim = 9 if less else int(c)
        for r in range(D):
            for d in range(lim+1):
                dp[i+1][less or d < lim][(r+d)%D] += dp[i][less][r]
                dp[i+1][less or d < lim][(r+d)%D] %= MOD

print((dp[-1][0][0] + dp[-1][1][0] - 1) % MOD)

# Buggy version:
MOD = 10**9 + 7
K = input()
N = len(K)
D = int(input())
S = [[0, 0] for i in range(D)]
S[0][0] = 1
for i in range(N):
    c = int(K[i])
    T = [[0, 0] for i in range(D)]
    for d in range(D):
        w0, w1 = S[d]
        w0 %= MOD
        w = S[d][0] % MOD
        for v in range(c):
            T[d+v-D][1] += w0
        T[d+c-D][0] += w0

        w1 %= MOD
        for v in range(10):
            T[d+v-D][1] += w1
    S = T
print((sum(S[0])-1) % MOD)

# Fixed version:
MOD = 10**9 + 7
K = input()
N = len(K)
D = int(input())

S = [[0, 0] for i in range(D)]
S[0][0] = 1
for i in range(N):
    c = int(K[i])
    T = [[0, 0] for i in range(D)]
    for d in range(D):
        w0, w1 = S[d]
        w0 %= MOD
        w = S[d][0] % MOD
        for v in range(c):
            T[(d+v)%D][1] += w0
        T[(d+c)%D][0] += w0

        w1 %= MOD
        for v in range(10):
            T[(d+v)%D][1] += w1
    S = T
print((sum(S[0])-1) % MOD)