#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>
#include <queue>

using namespace std;

vector<string> list;

void Func(string s,int num, array<bool, 26> check){
    if(num >= s.size()){
        list.push_back(s);
        return;
    }
    int c = int(s[num] - 'a');
    if(check[c] || s[num] == 'a'){
        Func(s, num + 1, check);
    }
    if(s[num] != 'z' && !check[c+1]){
        check[c+1] = true;
        s[num] = char(s[num] + 1);
        Func(s, num + 1, check);
    }
}

int main(){
    while(true){
        list.clear();
        string s;
        cin >> s;
        if(s == "#") break;

        array<bool, 26> check;
        for(int i = 0; i < 26; ++i) check[i] = false;
        Func(s, 0, check);
        sort(list.begin(), list.end());
        cout << list.size() << endl;
        if(list.size() <= 10){
            for(const auto& c : list){
                cout << c << endl;
            }
        } else {
            for(int i = 0; i < 5; ++i) cout << list[i] << endl;
            for(int i = list.size()-5; i < list.size(); ++i) cout << list[i] << endl;
        }
    }
}
