let id x = x

let init n f =
  let rec g i ns = if i = 0 then 0 :: ns else g (i - 1) (i :: ns) in
  List.map f (g n [])

let split_string ?(pattern="") = Str.split @@ Str.regexp pattern

let s = split_string @@ Scanf.scanf "%s\n" id

let f (lst, arr) a =
  match arr with
    | [] -> failwith ""
    | x :: xs -> (a, if a = lst then (x + 1) :: xs else 1 :: x :: xs)

let ss = 
  let t = List.rev_append 
    (if List.hd (List.rev s) = "<" then [0] else [])
    (snd @@ List.fold_left f (List.hd s, [1]) (List.tl s)) in
  if List.hd s = ">" then 0 :: t else t

let rec g = function
  | ([] | _ :: []) -> []
  | x :: y :: xs -> if x > y then x :: (y - 1) :: g xs else (x - 1) :: y :: g xs

let () = 
  ss
    |> g 
    |> List.map (fun i -> i * (i + 1) / 2) 
    |> List.fold_left (+) 0
    |> print_int;
  print_newline ()