#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */			

void solve()
{     string s;
      int n,k,i,x,y,j,i1,ans=0;
    cin >> s >> k;
    n=s.size();
    if(k==1)
    {
        if(n==1)
        {cout<<s;return;}
        else 
        {   x=s[0]-'0';
            cout<<(x + 9*(n-1));
            return ;
        }

    }
    else if(k==2)
    {
        if(n==1)cout<<"0";
        else if(n==2)
        {
            x=s[0]-'0';
            y=(s[0]-'0')*10 + (s[1]-'0');
            y-=11;
            if(x>=2)y-=(x-2);
            cout<<y;return ;
        }
        else 
        {
            for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                {
                    if(i!=0)
                    ans+=81;
                    else if (j==1)
                    {
                        ans+=(s[1]-'0');
                        for(int i1=1;i1<(s[0]-'0');i1++)
                        ans+=9;
                    }
                    else if(j==(n-1))ans+= (s[n-1]-'0') +(s[0]-'1')*9;
                     else ans+=(s[0]-'0')*9;
                    ans%=mod;
                }
            }
            cout << ans%mod ;
        }
    }
    else if(k==3)
    {
        if(n<=2)cout<<"0";
        else 
        {
            for(i=0;i<n;i++)
            {
                for(j=i+1;j<n;j++)
                {
                    for(i1=j+1;i1<n;i1++)
                    {
                        if(i!=0)
                        ans+=729;
                        else if(j!=1)
                        {
                            ans+=81+(s[0]-'1')*81;
                        }
                        else if(i1!=2)
                        {
                            ans+=9+(s[1]-'1')*9 + (s[0]-'1')*81;
                        }
                        else ans+=(s[2]-'0')+(s[1]-'1')*9 + (s[0]-'1')*81;
                        ans%=mod;
                    }
                }
            }
            cout<<ans%mod;
        }
    }
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		


