#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1195&lang=jp

vector<string> str;

bool check(string words, string& S) {
	int alpha[26] = { 0 }; alpha[0] = 1;
	for (int i = 0; i < words.length(); i++) {
		if (alpha[words[i] - 'a'] != 0) {
			if (words[i] != S[i])return false;
			continue;
		}
		alpha[words[i] - 'a'] = 1;
		words[i] = (char)(words[i] - 1);
		if (words[i] != S[i])return false;
	}
	return words == S;
}

void rec(int n,string words, string& S) {
	if (words.length() == S.length()) {
		if (check(words, S)) {
			str.push_back(words);
		}
		return;
	}

	rec(n + 1, words + S[n], S);
	rec(n + 1, words + char(S[n] + 1), S);
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	string S;
	while (cin >> S) {
		if (S == "#")break;
		str.clear();
		rec(0, "", S);

		cout << str.size() << endl;
		if (str.size() <= 10) {
			for (auto s : str) cout << s << endl;
		}
		else {
			for (int i = 0; i < 5;i++) cout << str[i] << endl;
			for (int i = str.size() - 5; i < str.size(); i++) cout << str[i] << endl;
		}
	}
}