#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define fi first
#define se second
template <typename A, typename B> inline bool chmax(A &a, B b) {if (a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmin(A &a, B b) {if (a > b) {a = b; return 1;} return 0;}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const double EPS = 1e-9;
const bool debug = 0;
/****************************/

int main() {
	string s;
	while (cin >> s, s != "#") {
		
		REP(i, s.size()) s[i] -= 'a';
		
		vector<string> ans;
		REP(i, 1<<s.size()) {
			int used = 0;
			string cur = "";
			bool ng = false;
			REP(j, s.size()) {
				if (ng) break;
				
				if (i >> j & 1) {
					if (s[j] == 25) ng = true;
					else {
						if (used >> (s[j] + 1) & 1) ng = true;
						else cur += s[j] + 1 + 'a';
						used |= 1 << (s[j] + 1);
					}
				}
				else {
					if (s[j] != 0 && !(used >> s[j] & 1)) ng = true;
					else cur += s[j] + 'a';
				}
			}
			if (count(ALL(cur), 'z') != 0 && !(used >> 25 & 1)) ng = true;
			if (!ng) ans.push_back(cur);
		}
		sort(ALL(ans));
		ans.erase(unique(ALL(ans)), ans.end());
		
		if (debug) printf("@ ");
		cout << ans.size() << endl;
		if (ans.size() <= 10) {
			REP(i, ans.size()) cout << ans[i] << endl;
		}
		else {
			REP(i, 5) cout << ans[i] << endl;
			for (int i = ans.size() - 5; i < ans.size(); i++) cout << ans[i] << endl;
		}
		
	}
}

