let () =
  let x = read_line () in
  Array.init (String.length x) (fun i -> x.[i])
  |> Array.fold_left (fun (h, m) -> function
    | 'S' -> (h + 1, m)
    | 'T' -> (h - 1, min m (h - 1))) (0, 0)
  |> (fun (h, m) ->
      let offset = min 0 m in
      let correct = h - offset in
      Printf.printf "%d\n" @@ correct - offset)