#include <bits/stdc++.h>
using namespace std;
#define int long long
int n_digs;
int pow_sum[10];
int pows[10];
int between(int a,int b,int a_digs,int n)
{
int k=n_digs-a_digs;
int ret=pow_sum[k-1];
a*=pows[k];
b*=pows[k];
ret+=max(0ll,min(n+1,b)-a);
return ret;
}
main()
{
int n,k;
cin>>n>>k;
n_digs=1+log10(n);
pows[1]=pow_sum[1]=10;
for(int i=2;i<10;i++)
{
pows[i]=10*pows[i-1];
pow_sum[i]=pows[i]+pow_sum[i-1];
}
int c_ord=1;
int c_num=1;
int c_dig=1;
while(c_ord<k)
{
int n_ord=c_ord+1+between(c_num,c_num+1,c_dig,n);
if(n_ord<=k)
{
c_num++;
c_ord=n_ord;
}
else
{
c_num*=10;
c_ord++;
c_dig++;
}
}
cout<<c_num<<endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBpbnQgbG9uZyBsb25nCgppbnQgbl9kaWdzOwppbnQgcG93X3N1bVsxMF07CmludCBwb3dzWzEwXTsKCmludCBiZXR3ZWVuKGludCBhLGludCBiLGludCBhX2RpZ3MsaW50IG4pCnsKICAgIGludCBrPW5fZGlncy1hX2RpZ3M7CiAgICBpbnQgcmV0PXBvd19zdW1bay0xXTsKICAgIGEqPXBvd3Nba107CiAgICBiKj1wb3dzW2tdOwogICAgcmV0Kz1tYXgoMGxsLG1pbihuKzEsYiktYSk7CiAgICByZXR1cm4gcmV0Owp9CgptYWluKCkKewogICAgaW50IG4sazsKICAgIGNpbj4+bj4+azsKICAgIG5fZGlncz0xK2xvZzEwKG4pOwoKICAgIHBvd3NbMV09cG93X3N1bVsxXT0xMDsKICAgIGZvcihpbnQgaT0yO2k8MTA7aSsrKQogICAgewogICAgICAgIHBvd3NbaV09MTAqcG93c1tpLTFdOwogICAgICAgIHBvd19zdW1baV09cG93c1tpXStwb3dfc3VtW2ktMV07CiAgICB9CgoKICAgIGludCBjX29yZD0xOwogICAgaW50IGNfbnVtPTE7CiAgICBpbnQgY19kaWc9MTsKICAgIHdoaWxlKGNfb3JkPGspCiAgICB7CiAgICAgICAgaW50IG5fb3JkPWNfb3JkKzErYmV0d2VlbihjX251bSxjX251bSsxLGNfZGlnLG4pOwogICAgICAgIGlmKG5fb3JkPD1rKQogICAgICAgIHsKICAgICAgICAgICAgY19udW0rKzsKICAgICAgICAgICAgY19vcmQ9bl9vcmQ7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIGNfbnVtKj0xMDsKICAgICAgICAgICAgY19vcmQrKzsKICAgICAgICAgICAgY19kaWcrKzsKICAgICAgICB9CiAgICB9CiAgICBjb3V0PDxjX251bTw8ZW5kbDsKfQo=