#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	while(true){
		string S;
		cin >> S;
		if(S == "#")break;
		set<string> st1, st2;
		st1.insert(S);
		for(char c = 'y'; c >= 'a'; c--){
			/*cout << "###############" << endl << c << endl;
			for(auto itr = st1.begin(); itr != st1.end(); itr++){
				cout << *itr << endl;
			}*/
			for(auto itr = st1.begin(); itr != st1.end(); itr++){
				string tmp = *itr;
				int posc=-1,poscpo=-1;
				for(int i = 0; i < tmp.size(); i ++){
					if(poscpo == -1 && tmp[i] == c+1){
						poscpo = i;
					}
					if(tmp[i] == c && poscpo == -1){
						tmp[i]++;
						st2.insert(tmp);
						tmp[i]--;
					}
				}
				if(poscpo == -1){
					st2.insert(tmp);
				}
			}
			st1 = st2;
			st2.erase(all(st2));
		}
		cout << st1.size() << endl;
		if(st1.size() <= 10){
			for(auto itr = st1.begin(); itr != st1.end(); itr++){
				cout << *itr << endl;
			}
		}
		else{
			auto itr = st1.begin();
			for(int i = 0; i < 5; i ++){
				cout << *itr << endl;
				itr++;
			}
			itr = st1.end();
			for(int i = 0; i < 5; i ++){
				itr--;
			}
			for(int i = 0; i < 5; i ++){
				cout << *itr << endl;
				itr++;
			}
		}
	}

	return 0;
}
