import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
// while (in.hasNextInt()) { // 注意 while 处理多个 case
// int a = in.nextInt();
// int b = in.nextInt();
// System.out.println(a + b);
// }
String line = in.nextLine();
String[] strs = line.split(" ");
int len = strs.length;
String word = strs[len - 2];
int index = 0;
String[] broWords = new String[len];
for (int i = 1; i < len - 2; i++) {
if (word.length() != strs[i].length()) {
continue;
}
boolean isBro = true;
for (int j = 0; j < word.length(); j++) {
if (!strs[i].contains(String.valueOf(word.charAt(j))) || getCharCount(strs[i], word.charAt(j)) != getCharCount(word, word.charAt(j))) {
isBro = false;
}
}
if (isBro && !strs[i].equals(word)) {
broWords[index] = strs[i];
index++;
}
}
int count = index;
for (int i = 0; i < index; i++) {
for (int j = i + 1; j < index; j++) {
if (broWords[j] == null) {
continue;
}
if (broWords[i] == null) {
broWords[i] = broWords[j];
count++;
}
if (broWords[i].equals(broWords[j])) {
broWords[j] = null;
count--;
continue;
}
if (broWords[i].compareTo(broWords[j]) > 0) {
String temp = broWords[i];
broWords[i] = broWords[j];
broWords[j] = temp;
}
}
}
System.out.println(index);
int ind = Integer.parseInt(strs[len - 1]);
if (ind <= count) {
System.out.print(broWords[ind - 1]);
}
}
private static int getCharCount(String s, char c) {
int count = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == c) {
count++;
}
}
return count;
}
}