fn read() -> Vec<char> {
    use std::io::*;
    let stdin = stdin();
    let s: Vec<char> = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    // s.split("").collect()
    s
}
fn main() {
    let mut vec: Vec<char> = read();
    let mut son_zai = true;
    while son_zai {
        son_zai = false;
        for c in 1..vec.len() {
            if vec[c - 1] == 'S' && vec[c] == 'T' {
                vec.remove(c - 1);
                vec.remove(c - 1);
                son_zai = true;
                break;
            }
        }
    }
    println!("{:?}", vec.len());
}
