#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

ll ans = 0;
vector<string> ss;

void dfs(string &s, char c) {
  if (c == 'a') {
    ss.push_back(s);
    return;
  }
  int ci = -1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == c) {
      ci = i;
      break;
    }
  }
  if (ci < 0) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == c - 1) {
        s[i] += 1;
        dfs(s, c - 1);
        s[i] -= 1;
      }
    }
    dfs(s, c - 1);
  } else {
    for (int i = 0; i < ci; i++) {
      if (s[i] == c - 1) {
        s[i] += 1;
        dfs(s, c - 1);
        s[i] -= 1;
      }
    }
  }
}

int main() {
  while (true) {
    string s;
    cin >> s;
    if (s == "#")
      break;
    ans = 0;

    dfs(s, 'z');

    cout << ss.size() << endl;

    sort(ss.begin(), ss.end());
    if (ss.size() < 10) {
      for (auto &v : ss) {
        cout << v << endl;
      }
    } else {
      for (int i = 0; i < 5; i++)
        cout << ss[i] << endl;
      for (int i = ss.size() - 5; i < ss.size(); i++)
        cout << ss[i] << endl;
    }
    ss.clear();
  }
  return 0;
}

