#include <bits/stdc++.h>
using namespace std;
int main(){
long long int a,b,ans,cnt=1,tmp;
while(cin>>a>>b){
if(a<0 && b<0) break;
ans=1;
tmp=a;
while(tmp!=1){
if(tmp%2==0) tmp/=2;
else tmp=3*tmp+1;
if(tmp>b) break;
ans++;
}
cout<<"Case "<<cnt++<<": A = "<<a<<", limit = "<<b<<", number of terms = "<<ans<<endl;
}
}