#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 100005;
struct item {
  int b;
  int p;
} D[MAXN], C[MAXN];
bool cmp(struct item n1, struct item n2) { return n1.b < n2.b; }
int b_s(int l, int r, int p, struct item* I) {
  int ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (p >= I[mid].p) {
      ans = max(ans, I[mid].b);
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return ans;
}
int main(void) {
  int n, c, d;
  while (scanf("%d%d%d", &n, &c, &d) != EOF) {
    int countc = 0, countd = 0;
    int b, p;
    char m[2];
    int maxc = 0, maxd = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d%d%s", &b, &p, m);
      if (m[0] == 'C' && c >= p) {
        C[countc].b = b;
        C[countc].p = p;
        countc++;
        maxc = max(b, maxc);
      } else if (m[0] == 'D' && d >= p) {
        D[countd].b = b;
        D[countd].p = p;
        countd++;
        maxd = max(b, maxd);
      }
    }
    if (maxc && maxd) {
      ans = maxc + maxd;
    }
    sort(C, C + countc, cmp);
    sort(D, D + countd, cmp);
    for (int i = 0; i < countc; i++) {
      if (countc == 1) break;
      int pp = c - C[i].p;
      int ans1 = 0;
      if (pp == 0) continue;
      if (i == 0) {
        ans1 = max(ans1, b_s(1, countc - 1, pp, C));
      } else if (i == countc - 1) {
        ans1 = max(ans1, b_s(0, countc - 2, pp, C));
      } else
        ans1 = max(b_s(0, i - 1, pp, C), b_s(i + 1, countc - 1, pp, C));
      if (ans1) ans = max(ans, ans1 + C[i].b);
    }
    for (int i = 0; i < countd; i++) {
      if (countd == 1) break;
      int pp = d - D[i].p;
      int ans2 = 0;
      if (pp == 0) continue;
      if (i == 0) {
        ans2 = max(ans2, b_s(1, countd - 1, pp, D));
      } else if (i == countd - 1) {
        ans2 = max(ans2, b_s(0, countd - 2, pp, D));
      } else
        ans2 = max(b_s(0, i - 1, pp, D), b_s(i + 1, countd - 1, pp, D));
      if (ans2) ans = max(ans, ans2 + D[i].b);
    }
    printf("%d\n", ans);
  }
  return 0;
}
