#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define FORR(i,a,b) for(int i=b-1;i>=a;i--)

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl

#define ALL(v) (v).begin(),(v).end()

int main(){
    while(true){
        string s;
        cin>>s;
        if(s=="#")break;
        vector<string> po[26];
        po[0].push_back(s);
        REP(i,25){
            char to = 'z'-i;
            char fr = 'z'-i-1;
            for(string s : po[i]){
                if(count(ALL(s),to)==0){
                    REP(j,s.size()){
                        if(s[j]==fr){
                            string t = s;
                            t[j] = to;
                            po[i+1].push_back(t);
                        }
                    }
                    po[i+1].push_back(s);
                }else{
                    REP(j,s.size()){
                        if(s[j]==fr){
                            string t = s;
                            t[j] = to;
                            po[i+1].push_back(t);
                        }else if(s[j]==to){
                            break;
                        }
                    }
                }
            }
        }
        printf("%d\n",(int)po[25].size());
        sort(ALL(po[25]));
        if(po[25].size() <= 10){
            REP(i,po[25].size()){
                printf("%s\n",po[25][i].c_str());
            }
        }else{
            REP(i,5)cout<<po[25][i]<<endl;
            REP(i,5)cout<<po[25][po[25].size()-5+i]<<endl;
        }
    }
    return 0;
}

