#include <vector>
#include <iostream>

using namespace std;

vector<string> ans;
bool ap[30];
string s;
int sum;

void dfs(int n,char c,string now){
//cout<<"dfs(int "<<n<<",char "<<c<<",string "<<now<<")"<<endl;
	if(n==s.size()){
		sum++;
		ans.push_back(now);
		return ;
	}
	if(ap[c-'a']==true || c=='a'){
		bool bac=ap[c-'a'];
		ap[c-'a']=true;
		dfs(n+1,s[n+1],now+c);
		ap[c-'a']=bac;
	}
	if(ap[c-'a'+1]==false && c!='z'){
		bool bac=ap[c-'a'+1];
		ap[c-'a'+1]=true;
		dfs(n+1,s[n+1],now+(char)(c+1));
		ap[c-'a'+1]=bac;
	}
}

int main(){
	while(1){
		while(!ans.empty())ans.pop_back();
		sum=0;
		cin>>s;
		if(s=="#")break;
		dfs(0,s[0],"");
		cout<<sum<<endl;

		if(sum<=10){
			for(int i=0;i<sum;i++){
				cout<<ans[i]<<endl;
			}
		}
		else{
			for(int i=0;i<5;i++){
				cout<<ans[i]<<endl;
			}
			for(int i=ans.size()-5;i<ans.size();i++){
				cout<<ans[i]<<endl;
			}
		}
	}
	return 0;
}