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 Rust (1.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        s: String,
    }
    let (s, zero_start) = (binary::from(&s), binary::from(&("01".repeat((s.len() + 1) / 2))));
    let buf = s.bits().iter().zip(zero_start.bits().iter())
        .map(|(l, r)| { (*l ^ *r) as i32 })
        .sum::<i32>();
    println!("{}", min(s.bits().len() - buf as usize, buf as usize));
}

mod binary {
    type SomeInt = i32;
    #[derive(Debug)]
    pub struct Binary {
        bits: Vec<u8>,
        to_int: Option<SomeInt>,
    }

    pub fn from(s: &str) -> Binary {
        Binary {
            bits: s.as_bytes().iter().map(|b| *b % 2).collect(),
            to_int: None::<SomeInt>,
        }
    }

    impl Binary {
        pub fn bits(&self) -> &Vec<u8> { &self.bits }
        // this function may cost a lot of computation
        pub fn to_int_expensive(&mut self) -> SomeInt {
            match self.to_int {
                Some(n) => n,
                None => {
                    self.to_int = Some(
                        self.bits.iter().rev().enumerate()
                            .map(|(i, &b)| {(2u8).pow(i as u32) as SomeInt * (b as SomeInt)})
                            .sum()
                    );
                    self.to_int.unwrap()
                }
            }
        }
    }
}
*/

fn main() {
    let exe = "/tmp/binA83B6DD3";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";