/* @judge_id: 1705PZ 694 C */
#include <stdio.h>

main()
{
	int term, count = 1;
	long long a, oa, limit;
	while(1) {
		scanf("%lld %lld", &a, &limit);
		if(a < 0 && limit < 0) { break; }
		oa = a; term = 1;
		while(1) {
			if ( a == 1 ) {
				break;
			} else if (a % 2 == 0) {
				a /= 2;
			} else {
				a = 3 * a + 1;
			}
			if( a > limit ) {
				break;
			}
			term++;
		}
		printf("Case %d: A = %lld, limit = %lld, number of terms = %d\n", count++, oa, limit, term);
	}
}
