#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<tuple>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define REPS(i, n) for(int i=1;i<=(int)n;i++)
#define RREP(i, n) for(int i=n-1;i>=0;i--)
#define RREPS(i, n) for(int i=n;i>0;i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back
#define endl '\n'
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int r, n, m;
string s;
vector<string> ans;

void dfs(string &s, int i, int used){
	if(i == s.size()){
		ans.pb(s);
		return ;
	}
	if(s[i]=='a' || (1&(used >> (s[i]-'a')))) dfs(s, i+1, used);
	if(s[i] < 'z' && 0 == (1&(used >> (s[i]-'a'+1)))){
		s[i] ++;
		dfs(s, i+1, used | (1 << (s[i]-'a')));
		s[i] --;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	while(cin >> s, s != "#"){
		n = s.size();
		dfs(s, 0, 0);
		cout << ans.size() << endl;
		if(ans.size() <= 10) for(auto &s : ans) cout << s << endl;
		else{
			REP(i, 5) cout << ans[i] << endl;
			REP(i, 5) cout << ans[ans.size()-5+i] << endl;
		}
		ans.clear();
	}
}