#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define pb push_back
#define L 26

string A = "abcdefghijklmnopqrstuvwxyz";
string T;
vector<string> V;
void dfs(string s, int r)
{
  if(r==0)
    {
      V.pb(s);
      return;
    }
  bool flag=true;
  int idx = 0;
  rep(i,s.size())
    {
      if(s[i]==A[r])
	{
	  flag=false;
	  break;
	}
      idx++;
    }
  rep(i,idx)
    {
      if(s[i]==A[r-1])
	{
	  s[i]=A[r];
	  dfs(s,r-1);
	  s[i]=A[r-1];
	}
    }
  if(flag)dfs(s,r-1);
}
int main()
{
  while(true)
    {
      cin >> T;
      if(T=="#")return 0;
      V.clear();
      dfs(T,25);
      printf("%d\n",V.size());
      sort(V.begin(),V.end());
      if(V.size()<=10)
	{
	  rep(i,V.size())
	    {
	      cout << V[i] << endl;
	    }
	}
      else
	{
	  rep(i,5)
	    {
	      cout << V[i] << endl;
	    }
	  rep(i,5)
	    {
	      cout << V[V.size()-5+i] << endl;
	    }
	}
    }
}