#include <bits/stdc++.h>
using namespace std;
struct node {
  int b, c;
};
int n, c, d;
int i, j;
node a[100010], b[100010];
int x[100010], y[100010];
int st[100010][20][2];
char s[10];
int na, nb;
bool operator<(node a, node b) { return a.c < b.c; }
int ask(int l, int r, int o) {
  if (l > r) return -1;
  int k = log2(r - l + 1);
  return max(st[l][k][o], st[r - (1 << k) + 1][k][o]);
}
int main() {
  scanf("%d%d%d", &n, &c, &d);
  for (i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    scanf("%s", s);
    if (s[0] == 'C') {
      na++;
      a[na].b = x;
      a[na].c = y;
    } else {
      nb++;
      b[nb].b = x;
      b[nb].c = y;
    }
  }
  if (na) sort(a + 1, a + na + 1);
  if (nb) sort(b + 1, b + nb + 1);
  for (i = 1; i <= na; i++) x[i] = a[i].c, st[i][0][1] = a[i].b;
  for (i = 1; i <= nb; i++) y[i] = b[i].c, st[i][0][2] = b[i].b;
  for (j = 1; (1 << j) <= na; j++) {
    for (i = 1; i + (1 << j) - 1 <= na; i++) {
      st[i][j][1] = max(st[i][j - 1][1], st[i + (1 << (j - 1))][j - 1][1]);
    }
  }
  for (j = 1; (1 << j) <= nb; j++) {
    for (i = 1; i + (1 << j) - 1 <= nb; i++) {
      st[i][j][2] = max(st[i][j - 1][2], st[i + (1 << (j - 1))][j - 1][2]);
    }
  }
  int ans = 0;
  if (na >= 2) {
    for (i = 1; i <= na; i++) {
      if (a[i].c > c) break;
      int lftc = c - a[i].c;
      int cur = a[i].b;
      int p = upper_bound(x + 1, x + na + 1, lftc) - x;
      p--;
      if (i <= p) {
        int q = max(ask(1, i - 1, 1), ask(i + 1, p, 1));
        if (q == -1)
          cur = 0;
        else
          cur += q;
      } else {
        int q = ask(1, p, 1);
        if (q == -1)
          cur = 0;
        else
          cur += q;
      }
      ans = max(ans, cur);
    }
  }
  if (nb >= 2) {
    for (i = 1; i <= nb; i++) {
      if (b[i].c > d) break;
      int lftd = d - b[i].c;
      int cur = b[i].b;
      int p = upper_bound(y + 1, y + nb + 1, lftd) - y;
      p--;
      if (i <= p) {
        int q = max(ask(1, i - 1, 2), ask(i + 1, p, 2));
        if (q == -1)
          cur = 0;
        else
          cur += q;
      } else {
        int q = ask(1, p, 2);
        if (q == -1)
          cur = 0;
        else
          cur += q;
      }
      ans = max(ans, cur);
    }
  }
  if (na && nb) {
    int p1 = upper_bound(x + 1, x + na + 1, c) - x;
    int p2 = upper_bound(y + 1, y + nb + 1, d) - y;
    p1--;
    p2--;
    if (p1 && p2) {
      ans = max(ans, ask(1, p1, 1) + ask(1, p2, 2));
    }
  }
  printf("%d\n", ans);
  return 0;
}
