def main():
    X = input()
    len_X = len(X)
    right_T = X.rfind("T")
    left_S = X.find("S")
    S_Count = X[left_S:right_T+1].count("S")
    T_Count = X[left_S:right_T+1].count("T")
    ans = len_X - min(T_Count, S_Count)*2
    print(ans)
if __name__ == "__main__":
    main()