#include <bits/stdc++.h>
using namespace std;
#define int long long
int between(int a,int b,int n)
{
int ret=0;
while(a<n)
{
a*=10,b*=10;
ret+=max(0ll,min(n+1,b)-a);
}
return ret;
}
main()
{
int n,k;
cin>>n>>k;
int c_ord=1;
int c_num=1;
while(c_ord<k)
{
int n_ord=c_ord+1+between(c_num,c_num+1,n);
if(n_ord<=k)
{
c_num++;
c_ord=n_ord;
}
else
{
c_num*=10;
c_ord++;
}
}
cout<<c_num<<endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBpbnQgbG9uZyBsb25nCgppbnQgYmV0d2VlbihpbnQgYSxpbnQgYixpbnQgbikKewogICAgaW50IHJldD0wOwogICAgd2hpbGUoYTxuKQogICAgewogICAgICAgIGEqPTEwLGIqPTEwOwogICAgICAgIHJldCs9bWF4KDBsbCxtaW4obisxLGIpLWEpOwogICAgfQogICAgcmV0dXJuIHJldDsKfQoKbWFpbigpCnsKICAgIGludCBuLGs7CiAgICBjaW4+Pm4+Pms7CiAgICBpbnQgY19vcmQ9MTsKICAgIGludCBjX251bT0xOwogICAgd2hpbGUoY19vcmQ8aykKICAgIHsKICAgICAgICBpbnQgbl9vcmQ9Y19vcmQrMStiZXR3ZWVuKGNfbnVtLGNfbnVtKzEsbik7CiAgICAgICAgaWYobl9vcmQ8PWspCiAgICAgICAgewogICAgICAgICAgICBjX251bSsrOwogICAgICAgICAgICBjX29yZD1uX29yZDsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgY19udW0qPTEwOwogICAgICAgICAgICBjX29yZCsrOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQ8PGNfbnVtPDxlbmRsOwp9Cg==