#include <bits/stdc++.h>
using namespace std;
int n, c, d;
const int maxn = 1e5 + 7;
struct node {
  int b, p;
  node(){};
  node(int b, int p) : b(b), p(p){};
};
vector<node> S[2];
bool cmp1(node a, node b) {
  if (a.p != b.p) return a.p < b.p;
  return a.b > b.b;
}
bool cmp2(node a, node b) { return a.b > b.b; }
int mxb[maxn], temp[maxn];
int main() {
  scanf("%d%d%d", &n, &c, &d);
  int b, p;
  for (int i = 0; i < n; ++i) {
    char s[2];
    scanf("%d%d%s", &b, &p, s);
    if (s[0] == 'C')
      S[0].push_back(node(b, p));
    else
      S[1].push_back(node(b, p));
  }
  int ans = 0, P = -1, Q = -1;
  if (S[0].size()) sort(S[0].begin(), S[0].end(), cmp2);
  if (S[1].size()) sort(S[1].begin(), S[1].end(), cmp2);
  for (int i = 0; i < S[0].size(); ++i) {
    if (S[0][i].p <= c) {
      P = S[0][i].b;
      break;
    }
  }
  for (int i = 0; i < S[1].size(); ++i) {
    if (S[1][i].p <= d) {
      Q = S[1][i].b;
      break;
    }
  }
  if (P != -1 && Q != -1) ans = P + Q;
  P = Q = -1;
  if (S[0].size()) sort(S[0].begin(), S[0].end(), cmp1);
  if (S[1].size()) sort(S[1].begin(), S[1].end(), cmp1);
  int all;
  for (int j = 0; j < 2; ++j) {
    if (j == 0)
      all = c;
    else
      all = d;
    if (S[j].size() == 0) continue;
    int prep = S[j][0].p, preb = S[j][0].b;
    for (int i = 1; i < S[j].size(); ++i) {
      if (S[j][i].p == prep) {
        int preP = P, preQ = Q;
        if (P == -1) {
          P = preb;
          Q = S[j][i].b;
        } else if ((preb + S[j][i].b) > (P + Q)) {
          P = preb;
          Q = S[j][i].b;
        }
        if (2 * prep > all) {
          P = preP, Q = preQ;
        }
        while (i < S[j].size() && S[j][i].p == prep) i++;
        if (i >= S[j].size()) break;
        prep = S[j][i].p, preb = S[j][i].b;
      } else {
        prep = S[j][i].p, preb = S[j][i].b;
      }
    }
    if (P != -1 && Q != -1) ans = max(ans, P + Q);
    P = Q = -1;
  }
  int tot = c;
  if (S[0].size()) {
    mxb[0] = S[0][0].b;
    temp[0] = S[0][0].p;
    for (int i = 1; i < S[0].size(); ++i) {
      mxb[i] = max(S[0][i].b, mxb[i - 1]);
      temp[i] = S[0][i].p;
    }
    for (int i = S[0].size() - 1; i >= 0; --i) {
      int A = S[0][i].p, B = tot - A;
      if (i == 0) continue;
      int lb = upper_bound(temp, temp + i, B) - temp;
      if (lb == 0) continue;
      ans = max(ans, S[0][i].b + mxb[lb - 1]);
    }
  }
  if (S[1].size()) {
    tot = d;
    mxb[0] = S[1][0].b;
    temp[0] = S[1][0].p;
    for (int i = 1; i < S[1].size(); ++i) {
      mxb[i] = max(S[1][i].b, mxb[i - 1]);
      temp[i] = S[1][i].p;
    }
    for (int i = S[1].size() - 1; i >= 0; --i) {
      int A = S[1][i].p, B = tot - A;
      if (i == 0) continue;
      int lb = upper_bound(temp, temp + i, B) - temp;
      if (lb == 0) continue;
      ans = max(ans, S[1][i].b + mxb[lb - 1]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
