Problem:
Score : 300 points

Problem Statement

N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.

The i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.

You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.

At least how many tiles need to be repainted to satisfy the condition?

Constraints

1 \leq |S| \leq 10^5

S_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the minimum number of tiles that need to be repainted to satisfy the condition.

Sample Input 1

000

Sample Output 1

1

The condition can be satisfied by repainting the middle tile white.

Sample Input 2

10010010

Sample Output 2

3

Sample Input 3

0

Sample Output 3

0

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Time Limit Exceeded)

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	// マップのキー
	// 0はじまり
	private final static String ANSWER1 = "answer1";
	// 1はじまり
	private final static String ANSWER2 = "answer2";

	public static void main(String[] args) {
		// 1. 入力データの処理
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		int sLength = input.length();
		int[] colorAry = new int[sLength];
		for(int i = 0; i < input.length(); i++) {
			colorAry[i] = Integer.valueOf(input.substring(i, i+1));
		}

		// 2. 正解となりうる2通りの文字列を作成
		// 決定因子:文字列の長さ
		Map<String, String> answerMap = new HashMap<>();
		answerMap = generateAnswer(sLength);

		// 3. キョリを計算し、少ない方とのキョリを出力
		printAnswer(input, answerMap);

	}

	/**
	 * キョリが小さい方を出力
	 * @param answerMap
	 */
	private static void printAnswer(String input, Map<String, String> answerMap) {
		// ANSWER1とのキョリ
		String result1 = answerMap.get(ANSWER1);
		int dis1 = calcDistance(input, result1);
		String result2 = answerMap.get(ANSWER2);
		int dis2 = calcDistance(input, result2);
		// 比較し、出力
		if(dis1 >= dis2) {
			System.out.println(dis2);
			return;
		} else {
			System.out.println(dis1);
			return;
		}
	}

	/**
	 * キョリの計算
	 * 想定:inputとanswerChoiceは同じ長さ
	 * @param answerChoice
	 * @return
	 */
	private static int calcDistance(String input, String answerChoice) {
		int distance = 0;
		for(int i = 0; i < input.length(); i++) {
			if(input.charAt(i) != answerChoice.charAt(i)) {
				distance += 1;
			}
		}
		return distance;
	}

	/**
	 * 正解となる文字列を格納するマップ作成
	 * @param length
	 * @return
	 */
	private static Map<String, String> generateAnswer(int length) {
		Map<String, String> result = new HashMap<>();
		String answer1 = new String();
		String answer2 = new String();
		for(int i = 0; i < length; i++) {
			if(i % 2 == 0) {
				answer1 += "0";
				answer2 += "1";
			} else {
				answer1 += "1";
				answer2 += "0";
			}
		}

		result.put(ANSWER1, answer1);
		result.put(ANSWER2, answer2);
		return result;
	}

}