#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

string s;
vector<string> cand;

int ans;
void dfs(int p, int C) {
    if (p == (int)s.size()) {
        cand.push_back(s);
        return;
    }
    // change
    int idx = (s[p] - 'a');
    if (~C >> idx & 1) {
        if (s[p] != 'z') {
            s[p]++;
            C ^= 1 << idx;
            dfs(p + 1, C);
            C ^= 1 << idx;
            s[p]--;
        }
    }
    // not change
    if (idx == 0 || C >> (idx - 1) & 1) {
        dfs(p + 1, C);
    }
}

int main() {
    while (cin >> s && s[0] != '#') {
        cand.clear();
        dfs(0, 0);
        cout << cand.size() << endl;
        sort(cand.begin(), cand.end());
        if (cand.size() <= 10) {
        } else {
            vector<string> new_cand;
            for (int i = 0; i < 5; ++i) {
                new_cand.push_back(cand[i]);
                new_cand.push_back(cand.rbegin()[i]);
            }
            cand = new_cand;
        }
        sort(cand.begin(), cand.end());
        for (auto &s : cand) cout << s << "\n";
    }
}