use std::collections::HashSet; fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().chars().collect::>(); let n = s.len(); let mut result = HashSet::new(); let mut x = 0isize; let mut y = 0isize; result.insert((x, y)); let mut indices = vec!['a', 'b', 'c']; for i in 0..n { let c = s[i]; let idx = indices.iter().enumerate().filter(|&(i, &target)| target == c).nth(0).unwrap().0; if i & 1 == 0 { match idx { 0 => { y += 1; indices.swap(1, 2); }, 1 => { x += 1; indices.swap(2, 0); }, 2 => { x -= 1; indices.swap(0, 1); }, _ => { unreachable!() }, }; } else { match idx { 0 => { y -= 1; indices.swap(1, 2); }, 1 => { x -= 1; indices.swap(2, 0); }, 2 => { x += 1; indices.swap(0, 1); }, _ => { unreachable!() }, }; } result.insert((x, y)); } println!("{}", result.len()); }