#include<bits/stdc++.h>
using namespace std;
long long n,k;
long long hs(long long a){
if(a<0)return 0;
long long h=a/10,x=a/100,y=a%10,sum=a/10+1,pp=10;
while(x!=0){
if(h%10==0)sum+=(x-1)*pp+y+1;
else sum+=x*pp;
y+=pp*(h%10);
pp*=10;
h/=10;
x/=10;
}
return sum;
}
int main(){
freopen("whz_number.in","r",stdin);
freopen("whz_number.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
while(cin>>n>>k){
long long bz=hs(n);
long long l=0,r=n,ans=0;
while(l<=r){
long long mid=(l+r)/2;
long long f=hs(mid-1);
if((bz-f)>=k)l=mid+1;
if((bz-f)==k)ans=mid;
if((bz-f)<k)r=mid-1;
}
cout<<ans<<endl;
}
return 0;
}