package codeJam;
import java.util.Scanner;
public class RevengeOfThePancakes {
	static Scanner sc=new Scanner(System.in);

	public static boolean[] readArray(String s){
		boolean[] ans=new boolean[s.length()];
		for(int x=0;x<s.length();x++) if(s.charAt(x)=='+') ans[x]=true;
		//System.out.println("readingFinished");
		return ans;
	}
	
	public static void runOnce(int caseNo){
		String inputLine=sc.nextLine();
		System.out.println("Case #"+(caseNo+1)+": "+noOfTurns(readArray(inputLine)));
	}
	
	public static void main(String[] args){
		int cases=Integer.parseInt(sc.nextLine());
		for(int caseNo=0;caseNo<cases;caseNo++) runOnce(caseNo);
	}
	
	public static int noOFSegments(boolean[] ar){
		boolean current=ar[ar.length-1];
		int blocks=1;
		for(int x=ar.length-1;x>-1;x--){
			if(current!=ar[x]){
				blocks++;
				current=!current;
			}
		}
		return blocks;
	}
	
	public static int noOfTurns(boolean[] ar){
		int ans=noOFSegments(ar);
		if(ans==1&&ar[0]) ans--;
		else if(ar[ar.length-1]) ans--;
		return ans;
	}
}

@@ -1,8 +1,647 @@
+/*%0D%0A%0D%0ACopyright Hackers' Club, University Of Peradeniya%0D%0AAuthor : Gihan Chanaka Jayatilaka (E/4/158)%0D%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0D%0Ayou may not use this file except in compliance with the License.%0D%0AYou may obtain a copy of the License at *%0D%0Ahttp://www.apache.org/licenses/LICENSE-2.0 *%0D%0AUnless required by applicable law or agreed to in writing, software%0D%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0ASee the License for the specific language governing permissions and%0D%0Alimitations under the License.%0D%0A*/%0D%0A%0D%0A
 package 

Update RevengeOfThePancakes.java