/* Problem 5--Hailstone Sequences
   There was nothing tricky about this one.  Just read the number and
   iterate through the sequence until you get to one. */

import java.io.*;
import java.util.*;

public class prob5 {

 public static Scanner in;
 public static PrintStream out;
 public static int cs;

 public static void main (String[] args) throws Exception {

  in = new Scanner (new File ("prob5.in"));
  out = new PrintStream (new FileOutputStream ("prob5.out"));
  int N=0;
  while ((N=in.nextInt())!=-1) {
   int ct=1; //loop until you reach one
   for (int sz = N;sz > 1; ct++) sz = sz%2==0 ? sz/2 : 3*sz+1;
   out.println ("Case "+(++cs)+": length = "+ct+" for N = "+N);
   out.println ();
  }
 }
}
