#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
vector<pair<int, int> > diamond, coin;
int dp[N][2] = {0}, dpp[N][2] = {0};
int main() {
  int n, c, d, x, y, mi = INT_MAX, mx = INT_MIN, j = 0, k = 0, a1 = 0, a2 = 0,
                     m1 = 0, m2 = 0, heera = 0, sona = 0;
  char ch;
  cin >> n >> c >> d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> ch;
    if (ch == 'D') {
      if (d >= y) a1 = max(a1, x);
      diamond.push_back(make_pair(y, x));
    } else {
      if (c >= y) a2 = max(a2, x);
      coin.push_back(make_pair(y, x));
    }
    mi = min(y, mi);
    mx = max(y, mx);
  }
  sort(diamond.begin(), diamond.end());
  sort(coin.begin(), coin.end());
  mx = max(mx, max(c, d));
  for (int i = mi; i <= 1e6; i++) {
    if ((j < coin.size() && coin[j - 1].first != i)) {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1];
      sona = i;
    }
    if ((k < diamond.size() && diamond[k - 1].first != i)) {
      dpp[i][0] = dpp[i - 1][0];
      dpp[i][1] = dpp[i - 1][1];
      heera = i;
    }
    if (j < coin.size() && coin[j].first == i) {
      if (coin[j].second > dp[i][0]) {
        dp[i][1] = dp[i][0];
        dp[i][0] = coin[j].second;
      } else if (coin[j].second > dp[i][1])
        dp[i][1] = coin[j].second;
      j++;
      sona = i;
      i--;
    }
    if (k < diamond.size() && diamond[k].first == i) {
      if (diamond[k].second > dpp[i][0]) {
        dpp[i][1] = dpp[i][0];
        dpp[i][0] = diamond[k].second;
      } else if (diamond[k].second > dpp[i][1])
        dpp[i][1] = diamond[k].second;
      k++;
      heera = i;
      i--;
    }
  }
  for (int i = heera + 1; i <= d; i++) {
    dpp[i][0] = dpp[i - 1][0];
    dpp[i][1] = dpp[i - 1][1];
  }
  for (int i = sona + 1; i <= c; i++) {
    dp[i][0] = dp[i - 1][0];
    dp[i][1] = dp[i - 1][1];
  }
  for (int i = 1; i <= d / 2; i++) {
    int p = 0;
    if (dpp[i][0] == dpp[d - i][0]) {
      if (dpp[i][0] && dpp[d - i][1]) p = dpp[i][0] + dpp[d - i][1];
    } else if (dpp[d - i][0] && dpp[i][0])
      p = dpp[d - i][0] + dpp[i][0];
    m1 = max(m1, p);
  }
  for (int i = 1; i <= c / 2; i++) {
    int p = 0;
    if (dp[i][0] == dp[c - i][0]) {
      if (dp[i][0] && dp[c - i][1]) p = dp[i][0] + dp[c - i][1];
    } else if (dp[c - i][0] && dp[i][0])
      p = dp[c - i][0] + dp[i][0];
    m2 = max(m2, p);
  }
  if (a1 && a2)
    cout << max(a1 + a2, max(m1, m2));
  else
    cout << max(m1, m2);
}
