### constant

CH_A = "a".ord
MAX_N = 10

### subroutines

def store(str)
  $count += 1
  $strs << str.clone
  $strs.sort!
  if $strs.length > MAX_N
    $strs.delete_at(MAX_N / 2)
  end
end

def rep_rec(k, str)
  if k < 0
    store(str)
    return
  end

  cur = (CH_A + k).chr
  nxt = (CH_A + k + 1).chr
  found = false

  for i in (0...str.length)
    case str[i]
    when nxt
      found = true
      break
    when cur
      str[i] = nxt
      rep_rec(k - 1, str)
      str[i] = cur
    end
  end

  if ! found
    rep_rec(k - 1, str)
  end
end

### main

loop do
  line = gets.strip
  break if line == '#'

  $count = 0
  $strs = []

  rep_rec(24, line)

  puts $count
  $strs.each{|str| puts str}
end