/*
* UVA_694.cpp
*
* Created on: 2013年10月6日
* Author: Administrator
*/
#include <stdio.h>
int main(){
long long a,l;//不要用int
int counter = 1;
while(scanf("%lld%lld",&a,&l)!=EOF,a!=-1 || l!= -1){
long long a1 = a;
int count = 1;
while(a != 1 ){
if( a%2 == 0 ){
a /= 2;
}else{
a = 3*a + 1;
}
if(a > l){
break;
}
count++;
}
printf("Case %d: A = %lld, limit = %lld, number of terms = %d\n",counter++,a1,l,count);
}
return 0;
}