use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let mut x = input.next();
    while x.contains("ST") {
        x = x.replace("ST", "");
    }
    println!("{}", x.len());
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            // line.split_whitespace().map(|x| println!("{}", String::from(x)));
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }

    fn next_i64(&mut self) -> i64 {
        return self.next().parse::<i64>().unwrap();
    }
}