
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
string n;
int ns;
string t[500000];
int pos;
int use[30];

bool che(string x,int cnt){
rep(i,26)use[i]=0;

rep(i,cnt){
	int tmp=x[i]-'a';
	if(!use[tmp]&&tmp>0){
		x[i]--;
		use[tmp]=1;
	}
}
	for(int i=0;i<cnt;i++)if(x[i]!=n[i])return 0;
	return 1;
	//return x==n;
}

void dfs(int now,string x){
	if(ns==now){

		if(che(x,ns))t[pos++]=x;
		return;
	}

	if(che(x+n[now],now+1))
	dfs(now+1,x+n[now]);

	if(n[now]!='z'){
		char a=n[now];
		a++;
		if(che(x+a,now+1))
		dfs(now+1,x+a);
	}

}

int main(){
while(cin>>n,n!="#"){

ns=n.size();
dfs(0,"");
cout<<pos<<endl;
if(pos<=10){
	rep(i,pos)cout<<t[i]<<endl;
}

else{
	rep(i,5)cout<<t[i]<<endl;
	for(int i=pos-5;i<pos;i++)cout<<t[i]<<endl;
}
rep(i,pos)t[i]="";
pos=0;
}
	return 0;
}
