1. 


/**
* FWP: Ausgewaehlte Probleme aus dem ACM (SS10)
*
* Method: ad hoc
* Problem: 694 - The Collatz Sequence
* Accepted: 1.784
* @author Evgeni Pavlidis
*
*/


import java.io.*;
import java.util.*;

class Main {

public static void main(String...args)
{
Scanner scanner = new Scanner(System.in);
long a, limit, c, i;
int caseNumber = 1;

while(true)
{
i = a = scanner.nextInt();
limit = scanner.nextInt();
if(a < 0 && limit < 0)
break;

c = 0;
while(a > 1 && a <= limit)
{
c++;
if(a % 2 == 0)
a /= 2;
else
a = a*3 + 1;
}

if(a == 1)
c++;

System.out.printf("Case %d: A = %d, limit = %d, number of terms = %d\n", caseNumber++, i, limit, c);
}
}
}