#include <bits/stdc++.h>
using namespace std;
int n, c, d;
const int maxn = 100000 + 10;
struct F {
  int b, p, o;
  F(int b = 0, int p = 0, int o = 0) : b(b), p(p), o(o) {}
} f[maxn];
std::vector<F> fc, fd;
bool cmp(const F A, const F B) {
  return A.b > B.b || (A.b == B.b && A.p < B.p);
}
bool cmp2(const F A, const F B) {
  return A.p < B.p || (A.p == B.p && A.b > B.b);
}
int maxv[maxn];
int solve() {
  sort(fc.begin(), fc.end(), cmp);
  sort(fd.begin(), fd.end(), cmp);
  int maxbc = 0, maxbd = 0;
  int maxV = 0;
  for (int i = 0; i < (int)fc.size(); ++i) {
    if (c >= fc[i].p) {
      maxbc = fc[i].b;
      break;
    }
  }
  for (int i = 0; i < (int)fd.size(); ++i) {
    if (d >= fd[i].p) {
      maxbd = fd[i].b;
      break;
    }
  }
  if (maxbc && maxbd) {
    maxV = maxbc + maxbd;
  }
  sort(fc.begin(), fc.end(), cmp2);
  sort(fd.begin(), fd.end(), cmp2);
  memset(maxv, 0, sizeof(maxv));
  for (int i = 1; i <= (int)fc.size(); ++i) {
    maxv[i] = max(maxv[i - 1], fc[i - 1].b);
  }
  int j = 0;
  for (int i = fc.size() - 1; i >= 0; --i) {
    while (j < i && fc[i].p + fc[j].p <= c) {
      j++;
    }
    j = min(j, i);
    if (j) {
      maxV = max(maxV, maxv[j] + fc[i].b);
    }
  }
  memset(maxv, 0, sizeof(maxv));
  for (int i = 1; i <= (int)fd.size(); ++i) {
    maxv[i] = max(maxv[i - 1], fd[i - 1].b);
  }
  j = 0;
  for (int i = fd.size() - 1; i >= 0; --i) {
    while (j < i && fd[i].p + fd[j].p <= d) {
      j++;
    }
    j = min(j, i);
    if (j) {
      maxV = max(maxV, maxv[j] + fd[i].b);
    }
  }
  return maxV;
}
int main(int argc, char const *argv[]) {
  char s[3];
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%s", &f[i].b, &f[i].p, s);
    f[i].o = (s[0] == 'C' ? 0 : 1);
    if (f[i].o)
      fd.push_back(f[i]);
    else
      fc.push_back(f[i]);
  }
  printf("%d\n", solve());
  return 0;
}
