#include <bits/stdc++.h>
using namespace std;
const long long INF = 10e17 + 7;
vector<pair<int, int> > a, b;
int bs(vector<pair<int, int> > &q, int l, int r, int cons) {
  int res = -1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (q[m].first <= cons) {
      res = m;
      l = m + 1;
    } else
      r = m - 1;
  }
  return res;
}
int bc[100010], bd[100010];
int main() {
  ios::sync_with_stdio(false);
  int n, c, d, max_c = 0, max_d = 0;
  cin >> n >> c >> d;
  for (int i = 0; i < n; i++) {
    char ch;
    int x, p;
    cin >> x >> p >> ch;
    if (ch == 'C' && p <= c)
      a.push_back({p, x}), max_c = max(x, max_c);
    else if (ch == 'D' && p <= d)
      b.push_back({p, x}), max_d = max(x, max_d);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int s_a = a.size(), s_b = b.size();
  int res = 0;
  if (s_a >= 1 && s_b >= 1) res = max(res, max_c + max_d);
  if (s_a >= 2) {
    for (int i = 0; i < s_a; i++) bc[i] = max(bc[i - 1], a[i].second);
    for (int i = 0; i < s_a; i++) {
      int pos;
      pos = bs(a, 0, i - 1, c - a[i].first);
      if (pos != -1) res = max(res, a[i].second + bc[pos]);
    }
  }
  if (s_b >= 2) {
    for (int i = 0; i < s_b; i++) bd[i] = max(bd[i - 1], b[i].second);
    for (int i = 0; i < s_b; i++) {
      int pos;
      pos = bs(b, 0, i - 1, d - b[i].first);
      if (pos != -1) res = max(res, b[i].second + bd[pos]);
    }
  }
  cout << res;
}
