let arr_of_str s = Array.init (String.length s) (fun i -> s.[i])
let _ = Scanf.scanf "%s" @@ fun s ->
  let l, a = Array.fold_left (fun (l,a) -> function
    | 'S' -> (l,a+1)
    | _ -> if a = 0 then (l+1,0) else (l,a-1)) (0,0) (arr_of_str s)
  in Printf.printf "%d\n" (l+a)