#include <iostream>
#include <string>
#include <vector>
using namespace std;

void dfs(int i, string const& s, string now, vector<bool>& used, vector<string>& res) {
    if(i == s.size()) {
        res.push_back(now);
        return;
    }
    if(s[i] == 'a' || used[s[i]-'a']) {
        dfs(i+1, s, now+s[i], used, res);
    }
    if(s[i] != 'z' && !used[s[i]-'a'+1]) {
        used[s[i]-'a'+1] = true;
        dfs(i+1, s, now+(char)(s[i]+1), used, res);
        used[s[i]-'a'+1] = false;
    }
}
int main() {
    string s;
    while(cin >> s, s != "#") {
        vector<bool> used(26, false);
        vector<string> res;
        dfs(0, s, "", used, res);
        cout << res.size() << endl;
        if(res.size() <= 10) {
            for(auto& x : res) {
                cout << x << endl;
            }
        } else {
            for(int i=0; i<5; ++i) {
                cout << res[i] << endl;
            }
            for(int i=0; i<5; ++i) {
                cout << res[res.size()-5+i] << endl;
            }
        }
    }
}
