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: Wrong Answer)

// 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: u64 = s.bits().iter().zip(zero_start.bits().iter())
        .map(|(l, r)| { *l ^ *r })
        .sum::<u8>() as u64;
    println!("{}", min(s.bits().len() - buf as usize, buf as usize));
}

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

    pub fn from(s: &str) -> Binary {
        let bits: Vec<u8> =  s.as_bytes().iter().map(|b| *b % 2).collect();
        let to_int = bits.iter().rev().enumerate()
            .map(|(i, &b)| 2u64.pow(i as u32) * (b as u64))
            .sum::<u64>() as SomeInt;
        Binary {bits, to_int }
    }

    impl Binary {
        pub fn bits(&self) -> &Vec<u8> { &self.bits }
        //pub fn to_int(&self) -> SomeInt { self.to_int }
    }
}
*/

fn main() {
    let exe = "/tmp/bin00FA9038";
    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>";