#include <bits/stdc++.h>
using namespace std;
long long int solve(vector<pair<long long int, long long int>> z,
                    long long int b, long long int pref[]) {
  sort(z.begin(), z.end());
  long long int cnt = z.size();
  if (cnt < 2) {
    return 0;
  }
  pref[0] = 0;
  for (long long int i = 0; i < cnt; i++) {
    pref[i + 1] = max(pref[i], z[i].second);
  }
  long long int i = 0;
  long long int res = 0;
  for (long long int j = cnt - 1; j >= 0; j--) {
    while (i < j && z[i].first + z[j].first <= b) {
      i++;
    }
    i = min(i, j);
    if (i > 0) {
      res = max(res, pref[i] + z[j].second);
    }
  }
  return res;
}
long long int m = 1000000007;
int main() {
  long long int n, c, d;
  cin >> n >> c >> d;
  long long int maxc = 0, maxd = 0;
  vector<pair<long long int, long long int>> coins, diamonds;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    char z;
    cin >> a >> b >> z;
    if (z == 'C') {
      if (b <= c) {
        coins.push_back({b, a});
        maxc = max(a, maxc);
      }
    } else {
      if (b <= d) {
        diamonds.push_back({b, a});
        maxd = max(a, maxd);
      }
    }
  }
  long long int maxb = 0;
  if (coins.size() >= 1 && diamonds.size() >= 1) maxb = maxc + maxd;
  if (coins.size() > 1) {
    long long int pre[coins.size() + 1];
    maxb = max(maxb, solve(coins, c, pre));
  }
  if (diamonds.size() > 1) {
    long long int pre[diamonds.size() + 1];
    maxb = max(maxb, solve(diamonds, d, pre));
  }
  cout << maxb << "\n";
  return 0;
}
