// Arup Guha
// 4/8/2016
// Solution to 2016 Code Jam Qualification Problem B: Revenge of the Pancakes.

import java.util.*;

public class b {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process all cases.
		for (int loop=1; loop<=numCases; loop++) {

			String pancakes = stdin.next();

			// We just need to count the changes...
			int res = 0;
			for (int i=0; i<pancakes.length()-1; i++)
				if (pancakes.charAt(i) != pancakes.charAt(i+1))
					res++;

			// If the bottom is a minus, we have that one last flip at the end. Count it and print.
			if (pancakes.charAt(pancakes.length()-1) == '-') res++;
			System.out.println("Case #"+loop+": "+res);
		}
	}
}