import java.io.*;
import java.io.IOException;
import java.lang.Thread.State;
import java.util.*;
//import javafx.util.Pair; 
//import java.util.concurrent.LinkedBlockingDeque;




    
  public class Main {
        
        public static long mod = (long)Math.pow(10, 9)+7 ;
        public static double epsilon=0.00000000008854;//value of epsilon
        public static InputReader sc = new InputReader(System.in);
        public static PrintWriter pw = new PrintWriter(System.out);
        
        public static ArrayList<ArrayList <Integer>> GetGraph(int n,int m){
            ArrayList<ArrayList <Integer>> g=new ArrayList<>();
            for(int i=0;i<n;i++){
                g.add(new ArrayList<>());
            }
            for(int i=0;i<m;i++){
                int t=sc.nextInt();
                int u=sc.nextInt()-1;
                int v=sc.nextInt()-1;
                g.get(u).add(v);
                if(t==0)
                g.get(v).add(u);
            }
            return g;
        }
        
        public static int find(int a,int p[]){
            if(a!=p[a]){
               p[a]=find(p[a], p);
            }
             return p[a];
        }
        public static void Union(int a,int b,int p[]){
            p[find(b, p)]=find(a, p);
        }
        public static long gcd(long a,long b){
            while(b>0){
                long t=b;
                b=a%b;
                a=t;
            }
            return a;
        }
        public static boolean dfs(ArrayList<ArrayList <Integer>> g,ArrayList<HashSet<Integer>> h,int u,int vis[]){
            vis[u]=1;
            boolean f=false;
            for(int i=0;i<g.get(u).size();i++){
                int v=g.get(u).get(i);
                if(vis[v]==1){

                }



                if(vis[v]==1){
                    if(h.get(v).contains(u)){
                        h.get(u).remove(v);
                    }
                    else f=true;
                }
                if(vis[v]==0)
                if(dfs(g, h,v, vis)){
                    if(h.get(v).contains(u)){
                        h.get(u).remove(v);
                    }
                    else f=true;
                }
                else{
                    if(h.get(v).contains(u)){
                        h.get(v).remove(u);
                    }
                }
            }
            vis[u]=2;
            return f;
        }
        public static long fun(int vis,int a[][],int n,long dp[][]){
            if(n<0)
            return 1;
            if(dp[n][vis]!=-1)
            return dp[n][vis];
            int l=a.length;
            dp[n][vis]=0;
            for(int i=0;i<l;i++){
                if(a[n][i]==1&&(vis&(1<<i))==0){
                    //vis|=(1<<i);
                    dp[n][vis]+=fun(vis|(1<<i), a, n-1,dp);
                    //vis^=(1<<i);
                    dp[n][vis]%=mod;
                }

            }
            return dp[n][vis];
        }
        
        public static int fun(int i,int k,int a[]){
            if(k==0){
                return a[i];
            }
            int j=1;
            while(k-2*j>0){
                j=2*j;
            }
            return fun(i, k-j, a)^fun(i+j, k-j, a);
        }
        public static long[][] multiply(long a[][], long b[][]) 
    { 
        long mul[][] = new long[a.length][b[0].length]; 
        for (int i = 0; i < a.length; i++) 
        { 
            for (int j = 0; j < b[0].length; j++) 
            { 
                mul[i][j] = 0; 
                for (int k = 0; k < a[0].length; k++) 
                    mul[i][j] += (a[i][k]* b[k][j])%mod;
                    mul[i][j] %= mod;
            }
        }
      
        return mul;
    
    } 
      
    public static long[][] power(long F[][], long n) 
    { 
        
    	long[][] result = new long[F.length][F.length];
    	for(int i=0; i<F.length; i++)
    		result[i][i] = 1;
    	
    	
    	while (n > 0) {
			if (n % 2 == 1)
				result = multiply(result, F);
			
			F = multiply(F, F);
			n = n / 2;
			//System.out.println("==");
		}
    	return result;
    }
    public static long modu(long p,long mod){
        if(p>=mod){
             p=-mod;
        }
        return p;
    }
        public static void main(String[] args) {
            // code starts..
            String s="0"+sc.nextLine();
            int n=sc.nextInt();
            long dp[][][]=new long[s.length()][n][2];
            dp[0][0][1]=1;
            /*for(int i=0;i<s.length()-1;i++){
                for(int p=0;p<=9;p++){
                    for(int r=0;r<n;r++){

                        int k=9;
                        for(int t=0;t<=k;t++){
                            dp[i+1][t][(r+t)%n][0]+=dp[i][p][r][0];
                            dp[i+1][t][(r+t)%n][0]%=mod;
                        }
                        if(p==s.charAt(i)-'0'){
                            k=s.charAt(i+1)-'0';
                            for(int t=0;t<k;t++){
                                dp[i+1][t][(r+t)%n][0]+=dp[i][p][r][1];
                                dp[i+1][t][(r+t)%n][0]%=mod;
                            }
                            dp[i+1][k][(r+k)%n][1]+=dp[i][p][r][1];
                            dp[i+1][k][(r+k)%n][1]%=mod;
                        }
                        
                        
                    }
                }
            }*/
            for(int i=0;i<s.length()-1;i++){
                //for(int p=0;p<=9;p++){
                    for(int r=0;r<n;r++){

                        int k=9;
                        

                        for(int t=0;t<=k;t++){
                            dp[i+1][(r+t)%n][0]+=dp[i][r][0];
                            dp[i+1][(r+t)%n][0]%=mod;
                        }
                        
                            k=s.charAt(i+1)-'0';
                            for(int t=0;t<k;t++){
                                dp[i+1][(r+t)%n][0]+=dp[i][r][1];
                                dp[i+1][(r+t)%n][0]%=mod;
                            }
                            dp[i+1][(r+k)%n][1]+=dp[i][r][1];
                            dp[i+1][(r+k)%n][1]%=mod;
                        
                        
                    }
                
            }
            
           long sum=0;
           
           //for(int i=0;i<=9;i++){
               sum+=dp[s.length()-1][0][0];
               sum%=mod;
               //pw.println(Arrays.toString(dp[s.length()-1][i]));
           //}
           sum+=dp[s.length()-1][0][1];
           sum=(sum+mod-1)%mod;
           pw.println(sum);
            
            
                         
            // Code ends...
            pw.flush();
            pw.close();
        }
       
        public static Comparator<Integer[]> column(int i){
            return 
            new Comparator<Integer[]>() {
                @Override
                public int compare(Integer[] o1, Integer[] o2) {
                    return o1[i].compareTo(o2[i]);//for ascending
                    //return o2[i].compareTo(o1[i]);//for descending
                }
            };
        }
        public static Comparator<Pair> C(){
            return 
            new Comparator<Pair>() {
                @Override
                public int compare(Pair o1, Pair o2) {
                    return o2.le-o1.le;//for des
                }
            };
        }
        
        public static Comparator<Integer[]> pair(){
            return 
            new Comparator<Integer[]>() {
                @Override
                public int compare(Integer[] o1, Integer[] o2) {
                    int result=o1[0].compareTo(o2[0]);
                    if(result==0)
                    result=o1[1].compareTo(o2[1]);
                    return result;
                }
            };
        }
        
        public static String reverseString(String s){
            StringBuilder input1 = new StringBuilder(); 
            input1.append(s);  
            input1 = input1.reverse();
            return input1.toString();
        }
        public static int[] scanArray(int n){
            int a[]=new int [n];
            for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
    
            return a;
        }
        public static long[] scanLongArray(int n){
            long a[]=new long [n];
            for(int i=0;i<n;i++)
            a[i]=sc.nextLong();
    
            return a;
        }
        public static String [] scanStrings(int n){
            String a[]=new String [n];
            for(int i=0;i<n;i++)
            a[i]=sc.nextLine();
    
            return a;
        }
        
    }
    
    class InputReader {
    
            private final InputStream stream;
            private final byte[] buf = new byte[8192];
            private int curChar, snumChars;
            private SpaceCharFilter filter;
    
            public InputReader(InputStream stream) {
                this.stream = stream;
            }
    
            public int snext() {
                if (snumChars == -1)
                    throw new InputMismatchException();
                if (curChar >= snumChars) {
                    curChar = 0;
                    try {
                        snumChars = stream.read(buf);
                    } catch (IOException e) {
                        throw new InputMismatchException();
                    }
                    if (snumChars <= 0)
                        return -1;
                }
                return buf[curChar++];
            }
    
            public int nextInt() {
                int c = snext();
                while (isSpaceChar(c)) {
                    c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                    sgn = -1;
                    c = snext();
                }
                int res = 0;
                do {
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    res *= 10;
                    res += c - '0';
                    c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
            }
    
            public long nextLong() {
                int c = snext();
                while (isSpaceChar(c)) {
                    c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                    sgn = -1;
                    c = snext();
                }
                long res = 0;
                do {
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    res *= 10;
                    res += c - '0';
                    c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
            }
    
            public int[] nextIntArray(int n) {
                int a[] = new int[n];
                for (int i = 0; i < n; i++) {
                    a[i] = nextInt();
                }
                return a;
            }
    
            public String readString() {
                int c = snext();
                while (isSpaceChar(c)) {
                    c = snext();
                }
                StringBuilder res = new StringBuilder();
                do {
                    res.appendCodePoint(c);
                    c = snext();
                } while (!isSpaceChar(c));
                return res.toString();
            }
    
            public String nextLine() {
                int c = snext();
                while (isSpaceChar(c))
                    c = snext();
                StringBuilder res = new StringBuilder();
                do {
                    res.appendCodePoint(c);
                    c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
            }
    
            public boolean isSpaceChar(int c) {
                if (filter != null)
                    return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
            }
    
            private boolean isEndOfLine(int c) {
                return c == '\n' || c == '\r' || c == -1;
            }
    
            public interface SpaceCharFilter {
                public boolean isSpaceChar(int ch);
            }
        }
        class Pair{
            int le;
            int p;
            Pair(int leaves,int parent){
                le=leaves;
                p=parent;
            }
        }
        
        
        

Measured memory_bytes: 86880