#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;

string s;
vector<string> ans;

void dfs(int idx, int used, string c) {
    if (idx == s.size()) {
        ans.push_back(c);
        return;
    }
    char now = s[idx];
    if ((used >> (now - 'a')) & 1) {
        dfs(idx + 1, used, c + now);
    }
    if (now != 'z' && !((used >> (now - 'a' + 1)) & 1)) {
        used |= (1 << (now - 'a' + 1));
        dfs(idx + 1, used, c + (char)(now + 1));
    }
    return;
}

int main() {
    while (cin >> s) {
        if (s == "#") break;
        ans.clear();
        dfs(0, 1, "");
        cout << ans.size() << endl;
        if (ans.size() <= 10) {
            for (auto e : ans) cout << e << endl;
        } else {
            for (int i = 0; i < 5; i++) cout << ans[i] << endl;
            for (int i = ans.size() - 5; i < ans.size(); i++) cout << ans[i] << endl;
        }
    }
    return 0;
}
