#include <bits/stdc++.h>
using namespace std;
const int MAX_STRING_LENGTH = 5e5 + 10;
struct _io {
  char buff[MAX_STRING_LENGTH];
  _io &operator>>(int &x) {
    scanf("%d", &x);
    return *this;
  }
  _io &operator>>(long long &x) {
    scanf("%lld", &x);
    return *this;
  }
  _io &operator>>(float &x) {
    scanf("%f", &x);
    return *this;
  }
  _io &operator>>(double &x) {
    scanf("%lf", &x);
    return *this;
  }
  _io &operator>>(long double &x) {
    scanf("%Lf", &x);
    return *this;
  }
  _io &operator>>(char &c) {
    do {
      scanf("%c", &c);
    } while (c == ' ' || c == '\n');
    return *this;
  }
  _io &operator>>(char *s) {
    scanf("%s", s);
    return *this;
  }
  _io &operator>>(string &s) {
    scanf("%s", buff);
    s = string(buff, strlen(buff));
    return *this;
  }
  _io &operator<<(const int x) {
    printf("%d", x);
    return *this;
  }
  _io &operator<<(const long long x) {
    printf("%lld", x);
    return *this;
  }
  _io &operator<<(const float x) {
    printf("%f", x);
    return *this;
  }
  _io &operator<<(const double &x) {
    printf("%lf", x);
    return *this;
  }
  _io &operator<<(const long double &x) {
    printf("%Lf", x);
    return *this;
  }
  _io operator<<(const char &c) {
    printf("%c", c);
    return *this;
  }
  _io &operator<<(const string &s) {
    printf("%s", s.c_str());
    return *this;
  }
  _io &operator<<(const char *s) {
    printf("%s", s);
    return *this;
  }
} io;
const int maxn = 5e3 + 10;
const long long MOD = 1e9 + 7;
using event = pair<int, pair<int, int>>;
int main() {
  int n;
  io >> n;
  auto v = vector<event>{};
  for (int i = 0; i < n; ++i) {
    string s;
    int b, e;
    io >> s >> b >> e;
    int g = -1;
    if (s == "M") {
      g = 1;
    } else {
      g = 0;
    }
    v.push_back({b, {1, g}});
    v.push_back({e, {2, g}});
  }
  sort(v.begin(), v.end());
  int m = 0;
  int f = 0;
  int ans = 0;
  for (auto &it : v) {
    if (it.second.first == 1) {
      if (it.second.second == 0) {
        ++f;
      } else {
        ++m;
      }
      ans = max(ans, min(m, f));
    } else {
      if (it.second.second == 0) {
        --f;
      } else {
        --m;
      }
    }
  }
  ans *= 2;
  io << ans;
  return 0;
}
