#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
char ch;

int k,kk,o,i,v[10000],len,len1[100000],oo,j,ii;
char s[10000],sub[60000][20],ss[60000][20];

void qt(int l,int r)
{
    int i,j;
    char m[1000],p[1000];
    i=l; j=r;
    strcpy(m,sub[(l+r)/2]);
    while (i<=j)
    {
        while (strcmp(sub[i],m)<0) i++;
        while (strcmp(sub[j],m)>0) j--;
        if (i<=j)
        {
            strcpy(p,sub[i]); strcpy(sub[i],sub[j]); strcpy(sub[j],p);
            i++; j--;
        }
    }
if (i<r) qt(i,r);
if (l<j) qt(l,j);
}


int main()
{
cin>>s;
cin>>k;
len=strlen(s);
o=0;
ch=123;
for (i=0;i<=len-1;i++)
if (v[i]==0)
{
    if (s[i]<ch) ch=s[i];
}
for (i=0;i<=len-1;i++)
if (s[i]==ch&&v[i]==0)
{
    o+=1;
    len1[o]=0;
    j=i;
    while (len1[o]<=10&&j<=len-1)
        {
          sub[o][len1[o]]=s[j];
          j+=1;
          oo=o+1;
          for (ii=0;ii<=len1[o];ii++)
            sub[oo][ii]=sub[o][ii];
          len1[o]+=1;
          len1[oo]=len1[o];
          sub[o][len1[o]]='\0';
          o+=1;
        }
    sub[o][len1[o]]='\0';
    v[i]=1;
}
ch=123;
for (i=0;i<=len-1;i++)
if (v[i]==0)
{
    if (s[i]<ch) ch=s[i];
}
for (i=0;i<=len-1;i++)
if (s[i]==ch&&v[i]==0)
{
    o+=1;
    len1[o]=0;
    j=i;
    while (len1[o]<=10&&j<=len-1)
        {
          sub[o][len1[o]]=s[j];
          j+=1;
          oo=o+1;
          for (ii=0;ii<=len1[o];ii++)
            sub[oo][ii]=sub[o][ii];
          len1[o]+=1;
          len1[oo]=len1[o];
          sub[o][len1[o]]='\0';
          o+=1;
        }
    sub[o][len1[o]]='\0';
    v[i]=1;
}
ch=123;
for (i=0;i<=len-1;i++)
if (v[i]==0)
{
    if (s[i]<ch) ch=s[i];
}
for (i=0;i<=len-1;i++)
if (s[i]==ch&&v[i]==0)
{
    o+=1;
    len1[o]=0;
    j=i;
    while (len1[o]<=10&&j<=len-1)
        {
          sub[o][len1[o]]=s[j];
          j+=1;
          oo=o+1;
          for (ii=0;ii<=len1[o];ii++)
            sub[oo][ii]=sub[o][ii];
          len1[o]+=1;
          len1[oo]=len1[o];
          sub[o][len1[o]]='\0';
          o+=1;
        }
    sub[o][len1[o]]='\0';
    v[i]=1;
}
ch=123;
for (i=0;i<=len-1;i++)
if (v[i]==0)
{
    if (s[i]<ch) ch=s[i];
}
for (i=0;i<=len-1;i++)
if (s[i]==ch&&v[i]==0)
{
    o+=1;
    len1[o]=0;
    j=i;
    while (len1[o]<=10&&j<=len-1)
        {
          sub[o][len1[o]]=s[j];
          j+=1;
          oo=o+1;
          for (ii=0;ii<=len1[o];ii++)
            sub[oo][ii]=sub[o][ii];
          len1[o]+=1;
          len1[oo]=len1[o];
          sub[o][len1[o]]='\0';
          o+=1;
        }
    sub[o][len1[o]]='\0';
    v[i]=1;
}
ch=123;
for (i=0;i<=len-1;i++)
if (v[i]==0)
{
    if (s[i]<ch) ch=s[i];
}
for (i=0;i<=len-1;i++)
if (s[i]==ch&&v[i]==0)
{
    o+=1;
    len1[o]=0;
    j=i;
    while (len1[o]<=10&&j<=len-1)
        {
          sub[o][len1[o]]=s[j];
          j+=1;
          oo=o+1;
          for (ii=0;ii<=len1[o];ii++)
            sub[oo][ii]=sub[o][ii];
          len1[o]+=1;
          len1[oo]=len1[o];
          sub[o][len1[o]]='\0';
          o+=1;
        }
    sub[o][len1[o]]='\0';
    v[i]=1;
}

qt(1,o);
strcpy(ss[1],sub[1]);
kk=1;
for (i=2;i<=o;i++)
    if (strcmp(sub[i],ss[kk])!=0) {kk++; strcpy(ss[kk],sub[i]);} else continue;

printf("%s",ss[k]);

    return(0);
}


Measured memory_bytes: 1664