'use strict';

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

let line = lines[0],
	depth = 0,
	removed = 0;

for (let c = 0; c < line.length; c++) {
	if (line[c] === 'S') {
		depth++;
	} else {
		if (depth > 0) {
			depth--;
			removed += 2;
		}
	}
}

console.log(line.length - removed);