import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

void main() {
    int N, M;
    bool input() {
        scanf("%d %d\n", &N, &M);
        if (N == 0 && M == 0) return false;
        return true;
    }
    void solve() {
        int[] step(in int[] xs) {
            auto ret = new int[xs.back >= 2 ? xs.length + 1 : xs.length];
            foreach (int i, x; xs) {
                ret[0] += x / 2;
                ret[i] += x % 2;
                if (x >= 2) {
                    ret[i + 1] += x / 2;
                }
            }
            return ret;
        }
        auto xs = [N];
        for (int i = 0; ; i++) {
            //writeln(xs);
            if (xs.length == M + 1) {
                writeln(i);
                break;
            }
            xs = step(xs);
        }
    }
    int T = 0;
    while (input) {
        writef("Case %d: ", ++T);
        solve;
    }
}