#include <bits/stdc++.h>
using namespace std;
vector<int> b[2], w[2];
int n, c, d;
int doit(int e, int a) {
  int mx = 0;
  set<pair<int, int> > q;
  vector<pair<int, int> > p;
  for (int i = 0, qwer = b[e].size(); i < qwer; i++)
    p.push_back(make_pair(w[e][i], b[e][i]));
  sort(p.begin(), p.end());
  int i = 0, j = p.size() - 1;
  while (j >= 0 && p[j].first > a) j--;
  while (j >= 0) {
    int nw = a - p[j].first;
    while (i < j && p[i].first <= nw) q.insert(make_pair(-p[i].second, i)), i++;
    bool f = 0;
    if (q.find(make_pair(-p[j].second, j)) != q.end()) {
      f = 1;
      q.erase(make_pair(-p[j].second, j));
    }
    if (!q.empty()) mx = max(-(*q.begin()).first + p[j].second, mx);
    if (f) q.insert(make_pair(-p[j].second, j));
    j--;
  }
  return mx;
}
int main() {
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 0, qwer = n; i < qwer; i++) {
    int x, y;
    char s[5];
    scanf("%d%d%s", &x, &y, s);
    if (s[0] == 'C')
      b[0].push_back(x), w[0].push_back(y);
    else
      b[1].push_back(x), w[1].push_back(y);
  }
  int mx = 0, cc = -1, cd = -1;
  for (int i = 0, qwer = b[0].size(); i < qwer; i++)
    if (w[0][i] <= c) cc = max(cc, b[0][i]);
  for (int i = 0, qwer = b[1].size(); i < qwer; i++)
    if (w[1][i] <= d) cd = max(cd, b[1][i]);
  if (cc != -1 && cd != -1) mx = cc + cd;
  mx = max(mx, doit(0, c));
  mx = max(mx, doit(1, d));
  printf("%d\n", mx);
  return 0;
}
