use std::collections::HashSet; fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().chars().map(|c| c as usize - 'a' as usize).collect::>(); let mut lines = vec![0,1,2]; let mut x = 0isize; let mut y = 0isize; let mut points = HashSet::new(); points.insert((x, y)); for &v in s.iter() { if v % 2 == 0 { match lines[v] { 0 => { y += 1; lines.swap(1, 2); }, 1 => { x += 1; lines.swap(2, 0); }, 2 => { x -= 1; lines.swap(0, 1); }, _ => { unreachable!() }, } points.insert((x, y)); } else { match lines[v] { 0 => { y -= 1; lines.swap(1, 2); }, 1 => { x -= 1; lines.swap(2, 0); }, 2 => { x += 1; lines.swap(0, 1); }, _ => { unreachable!() }, } points.insert((x, y)); } } println!("{}", points.len()); }