#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
vector<string>v;
string s;
bool b[200];
void dfs(int d){
    if(d==s.size())v.push_back(s);
    else{
        if(s[d]=='a'||b[s[d]])dfs(d+1);
        if(!b[s[d]+1]&&s[d]!='z'){
            s[d]++;
            b[s[d]]=1;
            dfs(d+1);
            b[s[d]]=0;
            s[d]--;
        }
    }
}
int main(){
    while(cin>>s,s!="#"){
        memset(b,0,sizeof(b));
        v.clear();
        dfs(0);
        cout<<v.size()<<endl;
        if(v.size()<=10)r(i,v.size())cout<<v[i]<<endl;
        else{
            r(i,5)cout<<v[i]<<endl;
            r(i,5)cout<<v[v.size()+i-5]<<endl;
        }
    }
}