/* Problem 2--Cryptograms
   This is a fairly straightforward text processing program.  As long as
   you keep meticulous track of the letters as you find them, you should
   be OK. */

import java.io.*;
import java.util.*;

public class prob2 {

 public static Scanner in=null;
 public static PrintWriter out=null;
 public static String s = "";
 public static int cs=1;

 public static void main (String[] args) throws Exception {

  in = new Scanner (new File ("prob2.in"));
  out = new PrintWriter ("prob2.out");
  while (in.hasNextLine()) {
   String t = "";
   s = "";
   do {
    t = in.nextLine(); //read in strings and paste them together
    if (!s.equals("") && !t.equals("")) s = s+" "+t;
    else s = s+t;
   } while (!t.equals(""));
   Process ();
  }
  in.close();
  out.close();
 }

 /* Process handles each data case, searching for E and then for THE */
 public static void Process () {

  int[] ct = new int[26];
  int max=0;
  char maxch = '@';
  for (int i=0; i < s.length(); i++)
   if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
    int p = s.charAt(i)-'A';
    ct[p]++;  //count the letters, keeping track of the most frequent
    if (ct[p] > max) {max = ct[p]; maxch = s.charAt(i);}
   }
  int[][] Grid = new int[26][26];
  char maxch1 = '@', maxch2 = '@';
  max = 0; //now count three letter combinations ending with E
  for (int i=2; i < s.length(); i++)
   if (s.charAt(i)==maxch && //make sure the three letters are different
       s.charAt(i-1) >= 'A' && s.charAt(i-1) <= 'Z' &&
       s.charAt(i-2) >= 'A' && s.charAt(i-2) <= 'Z' &&
       s.charAt(i-1) != maxch && s.charAt(i-2) != maxch &&
       s.charAt(i-1) != s.charAt (i-2)) {
    int p1 = s.charAt(i-2)-'A', p2 = s.charAt(i-1)-'A';
    Grid[p1][p2]++;
    if (Grid[p1][p2] > max) {
     max = Grid[p1][p2];
     maxch1 = s.charAt(i-2); maxch2 = s.charAt(i-1);
    }
   }
  out.print ("Case "+(cs++)+":  "); //print out the partially decrypted
  for (int i=0; i < s.length(); i++) //text
   if (s.charAt(i) < 'A' || s.charAt(i) > 'Z') out.print (s.charAt(i));
   else if (s.charAt(i) == maxch) out.print ('E');
   else if (s.charAt(i) == maxch1) out.print ('T');
   else if (s.charAt(i) == maxch2) out.print ('H');
   else out.print ('_');
  out.println (); out.println ();
 }
}
