// Arup Guha
// 5/20/2016
// Solution to 2014 NCNA Problem A: Binary Search Efficiency Decoder

import java.util.*;

public class binary {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int caseNum = 1;

		// Process each case.
		while (stdin.hasNext()) {

			// Get this case.
			int n = stdin.nextInt();

			int res = 0, pow2 = 1, level = 1;

			// Add up searches at each level...
			while (n > 0) {

				// Get the number of items found at this level and add into our accumulator.
				int items = Math.min(pow2, n);
				res += level*items;

				// Update for the next level of search.
				n -= items;
				pow2 <<= 1;
				level++;
			}

			// Output result.
			System.out.println("Case "+caseNum+": "+res);
			caseNum++;
		}
	}
}
