using System;
using System.Linq;
class Program{
    static void Main(){
        char[] x = Console.ReadLine().ToCharArray();
        int ans=0;
        for (int i=0;i<x.Length;i++){
            if (x[x.Length-i-1]=='S')
                continue;
            ans=i;
            break;
        }
        int c=ans;
        for (int i=0;i<x.Length-ans;i++){
            if (x[i]=='S')
                ans--;
            else
                ans++;
        }
        Console.WriteLine((ans==0)?0:ans+1);
    }
}