#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 5e5 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 998244353;
int t[maxn << 2], n;
struct node {
  int b, p;
} c[maxn], d[maxn];
bool cmp(node a, node b) { return a.b < b.b; }
void build(int l, int r, int rt) {
  t[rt] = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
}
void update(int l, int r, int v, int p, int rt) {
  if (l == r)
    t[rt] = max(t[rt], v);
  else {
    int mid = (l + r) >> 1;
    if (p <= mid)
      update(l, mid, v, p, rt << 1);
    else
      update(mid + 1, r, v, p, rt << 1 | 1);
    t[rt] = max(t[rt << 1], t[rt << 1 | 1]);
  }
}
int query(int l, int r, int L, int R, int rt) {
  if (L <= l && r <= R) return t[rt];
  int mid = (l + r) >> 1;
  int ans = 0;
  if (L <= mid) ans = max(ans, query(l, mid, L, R, rt << 1));
  if (R > mid) ans = max(ans, query(mid + 1, r, L, R, rt << 1 | 1));
  return ans;
}
int main() {
  int x, y, ccnt = 0, dcnt = 0, maxc = -1, maxd = -1;
  scanf("%d%d%d", &n, &x, &y);
  memset(c, 0, sizeof(c));
  memset(d, 0, sizeof(d));
  for (int i = 1; i <= n; i++) {
    int b, p;
    char t[2];
    scanf("%d%d %s", &b, &p, &t);
    if (t[0] == 'C') {
      if (p <= x) {
        c[ccnt].b = b;
        c[ccnt++].p = p;
        maxc = max(maxc, c[ccnt - 1].b);
      }
    } else {
      if (p <= y) {
        d[dcnt].b = b;
        d[dcnt++].p = p;
        maxd = max(maxd, d[dcnt - 1].b);
      }
    }
  }
  sort(c, c + ccnt, cmp);
  sort(d, d + dcnt, cmp);
  int maxx = (maxc == -1 || maxd == -1) ? -1 : (maxc + maxd);
  int ok1 = (maxx == -1) ? 0 : 1;
  int ok2 = 0, ok3 = 0;
  build(1, 100000, 1);
  for (int i = 0; i < ccnt; i++) {
    int tem = c[i].b, temp = 0;
    if (x != c[i].p) {
      temp = query(1, 100000, 1, x - c[i].p, 1);
    }
    if (temp != 0) {
      ok2 = 1;
      maxx = max(maxx, tem + temp);
    }
    update(1, 100000, tem, c[i].p, 1);
  }
  build(1, 100000, 1);
  for (int i = 0; i < dcnt; i++) {
    int tem = d[i].b, temp = 0;
    if (y != d[i].p) temp = query(1, 100000, 1, y - d[i].p, 1);
    if (temp != 0) {
      ok3 = 1;
      maxx = max(maxx, tem + temp);
    }
    update(1, 100000, tem, d[i].p, 1);
  }
  if (ok1 || ok2 || ok3)
    printf("%d\n", maxx);
  else
    printf("0\n");
}
