#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, w;
};
node a[100010];
node b[100010];
bool cmp(node a, node b) {
  if (a.w != b.w)
    return a.w < b.w;
  else
    return a.v > b.v;
}
int tree[100010 << 2];
void pushup(int cnt) { tree[cnt] = max(tree[cnt << 1], tree[cnt << 1 | 1]); }
void update(int p, int c, int l, int r, int cnt) {
  if (l == p && p == r) {
    tree[cnt] = max(tree[cnt], c);
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    update(p, c, l, mid, cnt << 1);
  else
    update(p, c, mid + 1, r, cnt << 1 | 1);
  pushup(cnt);
}
int query(int L, int R, int l, int r, int cnt) {
  if (L <= l && r <= R) {
    return tree[cnt];
  }
  int ans = 0;
  int mid = (l + r) >> 1;
  if (L <= mid) ans = max(ans, query(L, R, l, mid, cnt << 1));
  if (R > mid) ans = max(ans, query(L, R, mid + 1, r, cnt << 1 | 1));
  return ans;
}
int main() {
  int n, c, d;
  scanf("%d %d %d", &n, &c, &d);
  char ch;
  int x, y;
  int cnt1 = 0, cnt2 = 0;
  int maxc = 0, maxd = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d %d %c", &x, &y, &ch);
    if (ch == 'C') {
      a[cnt1].v = x;
      a[cnt1++].w = y;
      maxc = max(maxc, y);
    } else if (ch == 'D') {
      b[cnt2].v = x;
      b[cnt2++].w = y;
      maxd = max(maxd, y);
    }
  }
  int t1 = 0, t2 = 0;
  for (int i = 0; i < cnt1; i++)
    if (a[i].w <= c) t1 = max(a[i].v, t1);
  for (int i = 0; i < cnt2; i++)
    if (b[i].w <= d) t2 = max(t2, b[i].v);
  int sum1 = 0;
  if (t1 && t2) sum1 += t1 + t2;
  sort(a, a + cnt1, cmp);
  sort(b, b + cnt2, cmp);
  int sum2 = 0;
  int flag = 0;
  for (int i = 0; i < cnt1; i++) {
    int t = 0;
    if (c >= a[i].w) {
      t += a[i].v;
      if (c > a[i].w) {
        t += query(1, c - a[i].w, 1, maxc, 1);
        if (t > a[i].v) {
          flag = 2;
          sum2 = max(sum2, t);
        }
      }
    }
    update(a[i].w, a[i].v, 1, maxc, 1);
  }
  if (flag < 2) sum2 = 0;
  memset(tree, 0, sizeof(tree));
  int sum3 = 0;
  flag = 0;
  for (int i = 0; i < cnt2; i++) {
    int t = 0;
    if (d >= b[i].w) {
      t += b[i].v;
      if (d > b[i].w) {
        t += query(1, d - b[i].w, 1, maxd, 1);
        if (t > b[i].v) {
          flag = 2;
          sum3 = max(sum3, t);
        }
      }
    }
    update(b[i].w, b[i].v, 1, maxd, 1);
  }
  if (flag < 2) sum3 = 0;
  printf("%d\n", max(sum1, max(sum2, sum3)));
  return 0;
}
