#import <Foundation/Foundation.h>
int main() {
	@autoreleasepool{
		char S[200002];
		scanf("%s",S);
		NSMutableString *s = [NSMutableString stringWithUTF8String:S];
		while([s rangeOfString:@"ST"].location != NSNotFound){
			[s replaceOccurrencesOfString:@"ST" withString:@"" options:0 range:NSMakeRange(0,[s length])];
		}
		printf("%ld\n", [s length]);
	}
}
