output_description: Print the K-th lexicographically smallest substring of K.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      s
      K
attempt: s = input()
  k = int(input())
  
  t = len(s)
  u = []
  u2 = []
  """for i in range(t):
      u.append([])"""
  for i in range(5):
      u.append([])
  
  for j in range(5):
      for i in range(t):
          u[j].append([])
  
  for i in range(t):
      u2.append([])
  
  
  for j in range(5):
      for i in range(t):
          if j == 0:
              if s[i] not in u2[j]:
                  u[j][i].append(s[i])
                  u2[j].append(s[i])
                  u[j][i].append(i)
          elif j == 1:
              if i + 1 < t:
                  if s[i] + s[i + 1] not in u2[j] and s[i] + s[i + 1] not in u2[j - 1]:
                      for r in range(j + 1):
                          if u[r][i] == []:
                              u[r][i].append(s[i] + s[i + 1])
                              u2[j].append(s[i] + s[i + 1])
                              u[r][i].append(i)
                              break
          elif j == 2:
              if i + 2 < t:
                  if (
                      s[i] + s[i + 1] + s[i + 2] not in u2[j]
                      and s[i] + s[i + 1] + s[i + 2] not in u2[j - 1]
                      and s[i] + s[i + 1] + s[i + 2] not in u2[j - 2]
                  ):
                      for r in range(j + 1):
                          if u[r][i] == []:
                              u[r][i].append(s[i] + s[i + 1] + s[i + 2])
                              u2[j].append(s[i] + s[i + 1] + s[i + 2])
                              u[r][i].append(i)
                              break
          elif j == 3:
              if i + 3 < t:
                  if (
                      s[i] + s[i + 1] + s[i + 2] + s[i + 3] not in u2[j]
                      and s[i] + s[i + 1] + s[i + 2] + s[i + 3] not in u2[j - 1]
                      and s[i] + s[i + 1] + s[i + 2] + s[i + 3] not in u2[j - 2]
                      and s[i] + s[i + 1] + s[i + 2] + s[i + 3] not in u2[j - 3]
                  ):
                      for r in range(j + 1):
                          if u[r][i] == []:
                              u[r][i].append(s[i] + s[i + 1] + s[i + 2] + s[i + 3])
                              u2[j].append(s[i] + s[i + 1] + s[i + 2] + s[i + 3])
                              u[r][i].append(i)
                              break
          elif j == 4:
              if i + 4 < t:
                  if (
                      s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4] not in u2[j]
                      and s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4]
                      not in u2[j - 1]
                      and s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4]
                      not in u2[j - 2]
                      and s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4]
                      not in u2[j - 3]
                      and s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4]
                      not in u2[j - 4]
                  ):
                      for r in range(j + 1):
                          if u[r][i] == []:
                              u[r][i].append(
                                  s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4]
                              )
                              u2[j].append(
                                  s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4]
                              )
                              u[r][i].append(i)
                              break
      """for i in range(t):
      for j in range(k):
          if j == 0:
              u[i].append(s[i])
          elif j == 1:
              u[i].append(s[i] + s[i + 1])
          elif j == 2:
              u[i].append(s[i] + s[i + 1] + s[i + 2])
          elif j == 3:
              u[i].append(s[i] + s[i + 1] + s[i + 2] + s[i + 3])
          elif j == 4:
              u[i].append(s[i] + s[i + 1] + s[i + 2] + s[i + 3] + s[i + 4])"""
  p = [0] * t
  n = "z" * 10000
  m = -1
  l = -1
  for i in range(5):
      for j in range(t + 5):
          if j < len(u[0]):
              if u[0][j] != []:
                  if u[0][j][0] <= n:
                      n = u[0][j][0]
                      m = u[0][j][1]
                      l = j
      # sorted(u[0])
      if i + 1 == k:
          print(n)
          # print(u[0][0].pop(0))
          exit()
      else:
          u[0].append(u[1 + p[m]][m])
          p[m] += 1
          u[0][l].pop(0)
          u[0][l].pop(0)
          n = "z" * 10000
          m = -1
          l = -1
  
problem_description: Statement
  
  You are given a string s. Among the **different** substrings of s, print the
  K-th lexicographically smallest one.
  
  A substring of s is a string obtained by taking out a non-empty contiguous
  part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings
  of s, while `ac`, `z` and an empty string are not. Also, we say that
  substrings are different when they are different as strings.
  
  Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings.
  X is lexicographically larger than Y if and only if Y is a prefix of X or
  x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
samples: [{"input": "aba\n    4", "output": "b\n    \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n    5", "output": "andat\n    \n\n* * *"}, {"input": "z\n    1", "output": "z"}]