#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int length;

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

int strCmp2(char* left,char* right){
	int i;

	if(strCmp(left,right))return 3;

	for(i=0;left[i] != '\0' && right[i] != '\0'; i++){
		if(left[i] != right[i]){
			if(left[i] < right[i])return 1;
			else{
				return 2;
			}
		}
	}
	if(left[i] == '\0')return 1;
	else{
		return 2;
	}
}

struct Info{
	bool operator<(const struct Info &arg) const{
		if(strCmp2(sentence,arg.sentence) == 2){
			return true;
		}else{
			return false;
		}
	};

	void allocate(){
		sentence = new char[21];
	}

	char* sentence;
};

char work[21],first[21];
queue<Info> Work[2];
priority_queue<Info> Q;
bool FLG;

void recursive(char sentence[21],int loc){

	if(loc == length){

		char to_change[21];

		for(int i = 0; i < length; i++)to_change[i] = 'z';
		to_change[length] = '\0';

		for(int i = 1; i <= 25; i++){
			for(int k = 0; k < length; k++){
				if(sentence[k] == 'a' + i){
					to_change[k] = 'a' + i -1;
					break;
				}
			}
		}

		for(int i = 0; i < length; i++){
			if(to_change[i] == 'z')to_change[i] = sentence[i];
		}

		if(strCmp(to_change,first)){
			Info info;
			info.allocate();
			strcpy(info.sentence,sentence);
			Q.push(info);
		}
		return;

	}

	if(sentence[loc] == 'a'){
		FLG = true;
		for(int k = 0; k <= loc-1; k++){
			if(sentence[k] == 'b'){
				FLG = false;
				break;
			}
		}
		if(FLG){
			char next[21];
			strcpy(next,sentence);
			next[loc] = 'b';
			recursive(next,loc+1);

			char next2[21];
			strcpy(next2,sentence);
			recursive(next2,loc+1);

		}else{
			char next2[21];
			strcpy(next2,sentence);
			recursive(next2,loc+1);
		}

	}else if(sentence[loc] == 'z'){
		char next2[21];
		strcpy(next2,sentence);
		recursive(next2,loc+1);
	}else{

		FLG = true;
		for(int k = 0; k <= loc-1; k++){
			if(sentence[k] == sentence[loc]+1){
				FLG = false;
				break;
			}
		}

		if(FLG){
			for(int k = 0; k <= loc-1; k++){
				if(sentence[k] == sentence[loc]){
					FLG = false;
					break;
				}
			}

			if(FLG){
				char next[21];
				strcpy(next,sentence);
				next[loc] = sentence[loc]+1;
				recursive(next,loc+1);
			}else{
				char next[21];
				strcpy(next,sentence);
				next[loc] = sentence[loc]+1;
				recursive(next,loc+1);

				char next2[21];
				strcpy(next2,sentence);
				recursive(next2,loc+1);
			}

		}else{
			char next2[21];
			strcpy(next2,sentence);
			recursive(next2,loc+1);
		}
	}
}

int main(){

	char buf[21];

	while(true){

		scanf("%s",first);
		if(first[0] == '#')break;

		strcpy(buf,first);

		for(length = 0; buf[length] != '\0'; length++);

		recursive(buf,0);

		printf("%d\n",Q.size());

		if(Q.size() <= 10){
			while(!Q.empty()){
				printf("%s\n",Q.top().sentence);
				Q.pop();
			}
		}else{
			for(int i = 0; i < 5; i++){
				printf("%s\n",Q.top().sentence);
				Q.pop();
			}
			while(Q.size() > 5)Q.pop();
			while(!Q.empty()){
				printf("%s\n",Q.top().sentence);
				Q.pop();
			}
		}
	}

	return 0;
}

Measured memory_bytes: 5544