'use strict';

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

let line = lines[0];
let line2;

do {
	line2 = line.replace(/ST/, '');
	if (line === line2) break;
	line = line2;
} while (true);

console.log(line.length);