#include <bits/stdc++.h>
using namespace std;
int n, tc, td, b[100005], p[100005], maxx, cur, maxd, maxc;
char t[100005];
set<pair<pair<int, int>, pair<int, int> > > c, d, a1, a2;
set<pair<pair<int, int>, pair<int, int> > >::iterator it, it1;
pair<pair<int, int>, pair<int, int> > q, w;
bool yes;
int main() {
  cin >> n >> tc >> td;
  for (int i = 0; i < n; i++) {
    cin >> b[i] >> p[i] >> t[i];
    if (t[i] == 'D' && p[i] <= td) {
      a1.insert(make_pair(make_pair(p[i], b[i]), make_pair(0, i + 1)));
      maxd = max(maxd, b[i]);
    } else if (t[i] == 'C' && p[i] <= tc) {
      a2.insert(make_pair(make_pair(p[i], b[i]), make_pair(0, i + 1)));
      maxc = max(maxc, b[i]);
    }
  }
  cur = 0;
  q.first.first = 0;
  q.first.second = 0;
  q.second.first = 0;
  q.second.second = 0;
  c.insert(q);
  d.insert(q);
  q.first.first = 200000;
  q.first.second = 200000;
  q.second.first = 200000;
  q.second.second = 200000;
  c.insert(q);
  d.insert(q);
  for (it = a2.begin(); it != a2.end(); ++it) {
    q = *it;
    if (q.first.first == 0 || q.first.first == 200000) continue;
    cur = max(cur, q.first.second);
    q.second.first = cur;
    c.insert(q);
  }
  for (it = a1.begin(); it != a1.end(); ++it) {
    q = *it;
    if (q.first.first == 0 || q.first.first == 200000) continue;
    cur = max(cur, q.first.second);
    q.second.first = cur;
    d.insert(q);
  }
  for (int i = 0; i < n; i++) {
    if ((t[i] == 'D' && p[i] > td) || (t[i] == 'C' && p[i] > tc)) continue;
    if (t[i] == 'D') {
      q.first.first = td - p[i];
      q.first.second = 200000;
      q.second.second = 200000;
      q.second.first = 200000;
      it = d.lower_bound(q);
      --it;
      w = *it;
      while (w.second.second == i + 1 ||
             (b[i] == w.second.first && w.second.first != w.first.second)) {
        --it;
        w = *it;
      }
      if (w.first.first == 0) continue;
      maxx = max(maxx, b[i] + w.second.first);
    } else {
      q.first.first = tc - p[i];
      q.first.second = 200000;
      q.second.second = 200000;
      q.second.first = 200000;
      it = c.lower_bound(q);
      --it;
      w = *it;
      while (w.second.second == i + 1 ||
             (b[i] == w.second.first && w.second.first != w.first.second)) {
        --it;
        w = *it;
      }
      if (w.first.first == 0) continue;
      maxx = max(maxx, b[i] + w.second.first);
    }
  }
  cout << max(maxx, (maxd && maxc) ? maxd + maxc : 0);
  return 0;
}
