#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream& operator>>(istream& is, vector<T>& v);
template<class T> ostream& operator<<(ostream& os, vector<T> const& v);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream&, const tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream& os, const tuple<T...>& t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream& operator<<(ostream& os, const tuple<T...>& t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream&, tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream& is, tuple<T...>& t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream& operator>>(istream& is, tuple<T...>& t){ _it<0>(is, t); return is; }
template<class T> istream& operator>>(istream& is, vector<T>& v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif


string ans[1<<20];
char s[32];
char t[32];

int main(){
#ifdef LOCAL
    freopen("in","r",stdin);
#endif
    while(~scanf("%s",s) && s[0]!='#'){
        int sz = 0;
        int n = strlen(s);
        rep(i,n) t[i] = s[i];
        t[n] = 0;
        int change[32];
        rep(mask,1<<n){
            bool ok = true;
            rep(i,n){
                ok &= s[i]!='z' || ~mask>>i&1;
            }
            if(!ok) continue;
            rep(i,n){
                t[i] = s[i] + (mask>>i & 1);
            }

            change[0] = 30;
            change[1] = 30;
            change[2] = 30;
            change[3] = 30;
            change[4] = 30;
            change[5] = 30;
            change[6] = 30;
            change[7] = 30;
            change[8] = 30;
            change[9] = 30;

            change[10] = 30;
            change[11] = 30;
            change[12] = 30;
            change[13] = 30;
            change[14] = 30;
            change[15] = 30;
            change[16] = 30;
            change[17] = 30;
            change[18] = 30;
            change[19] = 30;

            change[20] = 30;
            change[21] = 30;
            change[22] = 30;
            change[23] = 30;
            change[24] = 30;
            change[25] = 30;
            change[26] = 30;
            change[27] = 30;
            change[28] = 30;
            change[29] = 30;

            change[30] = 30;
            change[31] = 30;

            rep(i,n){
                change[t[n-i-1]-'a'] = n-i-1;
            }

            change[0] = 30;

            t[change[0]]--;
            t[change[1]]--;
            t[change[2]]--;
            t[change[3]]--;
            t[change[4]]--;
            t[change[5]]--;
            t[change[6]]--;
            t[change[7]]--;
            t[change[8]]--;
            t[change[9]]--;

            t[change[10]]--;
            t[change[11]]--;
            t[change[12]]--;
            t[change[13]]--;
            t[change[14]]--;
            t[change[15]]--;
            t[change[16]]--;
            t[change[17]]--;
            t[change[18]]--;
            t[change[19]]--;

            t[change[20]]--;
            t[change[21]]--;
            t[change[22]]--;
            t[change[23]]--;
            t[change[24]]--;
            t[change[25]]--;
            t[change[26]]--;
            t[change[27]]--;
            t[change[28]]--;
            t[change[29]]--;

            t[change[30]]--;
            t[change[31]]--;

            if(strcmp(t,s)==0){
                rep(i,n){
                    t[i] = s[i] + (mask>>i&1);
                }
                ans[sz++] = t;
            }
        }
        sort(ans, ans + sz);
        printf("%d\n",sz);
        if(sz > 10){
            rep(i,5) printf("%s\n", ans[i].c_str());
            rep(i,5) printf("%s\n", ans[sz-5+i].c_str());
        } else {
            rep(i,sz){
                printf("%s\n",ans[i].c_str());
            }
        }
    }
}

Measured memory_bytes: 10496