#include <bits/stdc++.h>
using namespace std;
int n, r, ses = 0, tes = 0;
string s;
int main() {
  scanf("%d", &n);
  cin >> s;
  r = s.length();
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'T') {
      tes++;
      if (tes <= ses) r -= 2;
    } else {
      ses++;
      tes = 0;
    }
  }
  printf("%d\n", r);
}
