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

string s;
vector<string> vs;
int cnt[26] = {};

void dfs(string t, int lev) {
  if (lev == (int)s.size()) {
    vs.emplace_back(t);
    return;
  }
  int pos = s[lev] - 'a';
  if (s[lev] == 'a' || cnt[pos]) {
    cnt[pos]++;
    dfs(t + s[lev], lev + 1);
    cnt[pos]--;
  }
  if (s[lev] < 'z' && !cnt[pos + 1]) {
    cnt[pos + 1]++;
    dfs(t + char(s[lev] + 1), lev + 1);
    cnt[pos + 1]--;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> s, s != "#") {
    vs.clear();
    dfs("", 0);
    cout << vs.size() << endl;
    if ((int)vs.size() <= 10) {
      for (string v : vs) {
        cout << v << endl;
      }
    } else {
      sort(vs.begin(), vs.end());
      for (int i = 0; i < 5; i++) {
        cout << vs[i] << endl;
      }
      for (int i = 4; i >= 0; i--) {
        cout << vs[vs.size() - 1 - i] << endl;
      }
    }
  }

  return 0;
}
