import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    string s;
    bool input() {
        s = readln.chomp;
        return s != "#";
    }
    bool[] used = new bool[26];
    bool Check(in char[] R) { // R: Raw
        used[] = false;
        char[] E = new char[R.length]; // Encrypted
        foreach (i; 0 .. R.length) {
            if (R[i] == 'a' || used[ R[i] - 'a' ]) {
                E[i] = R[i];
            } else {
                E[i] = cast(char)(R[i] - 1);
                used[ R[i] - 'a' ] = true;
            }
        }
        return E == s;
    }
    void solve() {
        string[] rs;
        char[] P = new char[s.length];
        void dfs(int index) {
            if (index == s.length) {
                if (!Check(P)) return;
                rs ~= cast(string)(P.dup);
                return;
            }
            char a = s[index],
                 b = cast(char)(s[index] + 1);
            if (a == 'z') {
                P[index] = 'z';
                dfs(index + 1);
            } else {
                P[index] = a;
                dfs(index + 1);
                P[index] = b;
                dfs(index + 1);
            }
        }
        dfs(0);
        writeln(rs.length);
        if (rs.empty) return;
        if (rs.length < 10) {
            writeln(rs.join("\n"));
        } else {
            string[] A1 = new string[5];
            topNCopy(rs, A1);
            string[] A2 = new string[5];
            topNCopy!"a > b"(rs, A2);
            writeln((A1 ~ A2).sort.join("\n"));
        }
    }
    while (input) solve;
}