;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;文字列 -> 整数
(defn Int [s] (Integer/parseInt s))
;文字列 -> 文字列
(defn Str [s] s)

;scanf的なノリで1行をいい感じに読み取る
;定数が重いので注意
(defn input [varTypes]
    (mapv 
        (fn [f s] (f s)) ;文字列sに関数fを適用する
        varTypes         ;適用する関数
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

;スペース区切りの整数を受け取る
;速い
(defn inputFast [varType]
    (map
        varType
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

(defn floor [a b] (quot a b))
(defn ceil [a b] (floor (- (+ a b) 1) b))
(defn abs [a] (if (> 0 a) (- 0 a) a))


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


;---main---
(dosync
    (def l1 (input [Str]))
    (def l2 (input [Int]))
    (let [[A] l1] (let [[K] l2]
        (def B (ref (list)))
        (def len (count A))
        (doseq [i (range 0 len)]
            (doseq [j (range 1 6)]
                (if (<= (+ i j) len)
                    (alter B conj (subs A i (+ i j)))
                )
            )
        )
        (alter B distinct)
        (alter B sort)
        (println (nth (deref B) (- K 1)))
    ))
)



