const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
// Write your code here
const line = await readline();
const arr = line.split(" ");
const X = arr[arr.length - 2];
const XSort = X.split("").sort().join("");
const res = [];
for (let i = 0; i <= arr.length - 3; i++) {
XLength = X.length;
if (arr[i].length == XLength) {
if (arr[i] !== X) {
const nCur = arr[i].split("").sort().join("");
if (nCur == XSort) {
// console.log("n", arr[i]);
res.push(arr[i]);
}
}
}
}
console.log(res.length);
if (arr[arr.length - 1] <= res.length) {
res.sort()
console.log(res[arr[arr.length - 1]-1])
}
})();