use proconio::input; fn main() { input! { s: String, } let mut removed_length = 0_usize; let mut lt_cnt = 0_usize; let mut stack = vec![]; for c in s.chars() { match c { '<' => { lt_cnt += 1; stack.push('<'); } '=' => { stack.push('='); } '>' => { if lt_cnt == 0 || stack.last() != Some(&'=') { lt_cnt = 0; stack.push('>'); } else { removed_length += 1; while let Some(prev_c) = stack.pop() { removed_length += 1; if prev_c == '<' { break; } } } } _ => panic!(), } } println!("{}", s.len() - removed_length); }