using System;
using System.Collections.Generic;
class Program
{
const int Hou = 1000000007;
static string InputPattern = "Input1";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
WillReturn.Add("100");
//33
//1以上100以下の3の倍数33個が条件を満たす。
}
else if (InputPattern == "Input2") {
WillReturn.Add("7");
WillReturn.Add("123456789012345678901234567890");
//468357804
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int D = int.Parse(InputList[0]);
string N = InputList[1];
// 場合の数[Dを法とした余り,数字自由フラグ]なDP表
long[,] PrevDP = new long[D, 2];
PrevDP[0, 0] = 1;
for (int I = 0; I <= N.Length - 1; I++) {
long[,] CurrDP = new long[D, 2];
for (int J = 0; J <= PrevDP.GetUpperBound(0); J++) {
for (int K = 0; K <= 1; K++) {
if (PrevDP[J, K] == 0) continue;
for (char NewChar = '0'; NewChar <= '9'; NewChar++) {
if (K == 0 && N[I] < NewChar) break;
int NewJ = (J + NewChar - '0') % D;
int NewK = K;
if (N[I] > NewChar) NewK = 1;
CurrDP[NewJ, NewK] += PrevDP[J, K];
CurrDP[NewJ, NewK] %= Hou;
}
}
}
PrevDP = CurrDP;
}
long Answer = 0;
Answer += PrevDP[0, 0]; Answer %= Hou;
Answer += PrevDP[0, 1]; Answer %= Hou;
Answer--; // 0の分を引く
if (Answer < 0) Answer += Hou;
Console.WriteLine(Answer);
}
}