#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
struct ft {
  int ft[N + 5];
  void update(int i, int v) {
    for (; i <= N; i += (i & -i)) {
      ft[i] = max(ft[i], v);
    }
  }
  int query(int i) {
    int res = 0;
    for (; i > 0; i -= (i & -i)) res = max(res, ft[i]);
    return res;
  }
} ft[2];
vector<pair<int, int> > C, D;
int main() {
  int n, c, d;
  scanf("%d%d%d", &n, &c, &d);
  int ans = 0;
  int ans1 = -1, ans2 = -1;
  for (int i = 1; i <= n; i++) {
    int b, p;
    char s[2];
    scanf("%d%d%s", &b, &p, s);
    if (s[0] == 'C') {
      C.emplace_back(pair<int, int>(p, b));
      if (p <= c) ans1 = max(ans1, b);
    } else {
      D.emplace_back(pair<int, int>(p, b));
      if (p <= d) ans2 = max(ans2, b);
    }
  }
  if (ans1 != -1 && ans2 != -1) ans = max(ans, ans1 + ans2);
  for (int i = 0; i < C.size(); i++) {
    int p = C[i].first, b = C[i].second;
    int diff = c - p;
    int q = 0;
    if (diff > 0) q = ft[0].query(diff);
    if (p < c && q != 0) ans = max(ans, q + b);
    ft[0].update(p, b);
  }
  for (int i = 0; i < D.size(); i++) {
    int p = D[i].first, b = D[i].second;
    int diff = d - p;
    int q = 0;
    if (diff > 0) q = ft[1].query(diff);
    if (p < d && q != 0) ans = max(ans, q + b);
    ft[1].update(p, b);
  }
  printf("%d\n", ans);
}
