#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 5;
int a[MaxN], b[MaxN];
int bty[MaxN], cost[MaxN];
char typ[MaxN];
int lowbit(int x) { return x & (-x); }
void add(int *t, int x, int w) {
  while (x <= MaxN) {
    t[x] = max(t[x], w);
    x += lowbit(x);
  }
}
int G(int *t, int x) {
  int res = 0;
  while (x > 0) {
    res = max(res, t[x]);
    x -= lowbit(x);
  }
  return res;
}
int main() {
  int n, c, d;
  while (~scanf("%d%d%d", &n, &c, &d)) {
    int ans = 0;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = 1; i <= n; i++) {
      int Max = 0;
      int bty, cost;
      char typ;
      scanf("%d %d %c", &bty, &cost, &typ);
      if (typ == 'C') {
        Max = G(b, d);
        if (cost > c) continue;
        Max = max(Max, G(a, c - cost));
        add(a, cost, bty);
      } else {
        Max = G(a, c);
        if (cost > d) continue;
        Max = max(Max, G(b, d - cost));
        add(b, cost, bty);
      }
      if (Max > 0) ans = max(ans, Max + bty);
    }
    printf("%d\n", ans);
  }
  return 0;
}
