use std::cmp::max;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s = sc.chars();
    if s.len() == 1 {
        println!("1");
        return;
    }

    let ans1 = solve(true, &s);
    let ans2 = solve(false, &s);
    println!("{}", max(ans1, ans2));
}

fn solve(mut prev_two: bool, s: &Vec<char>) -> usize {
    let mut ans = 1;
    let n = s.len();
    let mut cur = if prev_two { 2 } else { 1 };
    while cur < n {
        if prev_two {
            prev_two = false;
            cur += 1;
            ans += 1;
        } else {
            if s[cur - 1] == s[cur] {
                if cur + 2 > n {
                    return 0;
                }
                cur += 2;
                ans += 1;
                prev_two = true;
            } else {
                cur += 1;
                ans += 1;
            }
        }
    }
    ans
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
