#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Max_es 20
#define Max_candsize (1<<20) // =2**20, (<<2 = *4)
char expr[Max_es+1];
char cands[Max_candsize][Max_es+1];
char expr_cp[Max_es+1];
int cands_ok[Max_candsize];

int main(){
	int len, nn;
	int i, j, k;

	while(1){
		int cands_num = 0;
		fgets(expr, Max_es+2, stdin);
		if(expr[0] == '#')
			break;
		len = strlen(expr)-1; // fgets??§???????????????????????????????????????
		
		nn = 1<<len;
		
		for(i = 0; i < nn; i++){
			char *cand = cands[i];
			for(j = 0; j < len; j++){
				expr_cp[j] = cands[i][j];
				if((i&(1<<j)) != 0)
					k = 1;
				else
					k = 0;
				cand[j] = expr[j] + k;
				expr_cp[j] = cands[i][j];
			}
			cand[len] = 0;
			for(j = 0; j < 25; j++){
				char com1 = 'a' +j + 1;
				char com2 = 'a' +j;
				for(k = 0; k < len ;k++){
					if(expr_cp[k] == com1){
						expr_cp[k] = com2;
						break;
					}
				}
			}
			for(j = 0; j < len; j++){
				if(expr_cp[j] != expr[j])
					break;
			}
			if(j == len){
				cands_ok[cands_num] = i;
				cands_num++;
			}
		}
		
		printf("%d\n", cands_num);
		if(cands_num <= 10){
			for(i = 0; i < cands_num; i++)
				printf("%s\n", cands[cands_ok[i]]);
		}
		else{
			for(i = 0; i < 5; i++)
				printf("%s\n", cands[cands_ok[i]]);
			for(i = (cands_num - 5); i < cands_num; i++)
				printf("%s\n", cands[cands_ok[i]]);
		}
		
	}
}