import java.io.*; import java.util.*; public class FindingTheTopRPSPlayer { private static final Scanner cin = new Scanner(System.in); public static void main(String[] args) { for(int iCase = 1; ; iCase++) { int n = cin.nextInt(); int m = cin.nextInt(); if(n == 0 && m == 0) { break; } System.out.println("Case " + iCase + ": " + solve(n, m)); } } private static int solve(int n, int m) { int[] p = new int[m+1]; p[0] = n; int j = 0; while(p[m] == 0) { int r = 0; j++; for(int i = m - 1; i >= 0; i--) { int q = p[i] / 2; p[i+1] += q; p[ i ] -= q * 2; r += q; } p[0] += r; } return j; } }