#include <bits/stdc++.h>
using namespace std;
const int _size = 1e5 + 13;
int pref[_size];
int solve(vector<pair<int, int> > p, int b) {
  sort(p.begin(), p.end());
  int cnt = p.size();
  if (cnt < 2) return 0;
  int res = 0;
  pref[0] = 0;
  for (int i = 0; i < cnt; i++) {
    pref[i + 1] = max(pref[i], p[i].second);
  }
  for (int i = cnt - 1; i > 0; i--) {
    int j = i - 1;
    while (j > 0 && p[i].first + p[j].first > b) j--;
    if (j >= 0 && p[i].first + p[j].first <= b) {
      res = max(res, p[i].second + pref[j + 1]);
    }
  }
  return res;
}
int main() {
  int n, c_total, d_total;
  vector<pair<int, int> > coin, diamond;
  cin >> n >> c_total >> d_total;
  for (int i = 0; i < n; i++) {
    int b, p;
    char c;
    cin >> b >> p >> c;
    if (c == 'C') {
      coin.push_back(make_pair(p, b));
    } else {
      diamond.push_back(make_pair(p, b));
    }
  }
  int res = 0, x = 0, y = 0;
  for (int i = 0; i < coin.size(); i++)
    if (coin[i].first <= c_total) x = max(x, coin[i].second);
  for (int i = 0; i < diamond.size(); i++)
    if (diamond[i].first <= d_total) y = max(y, diamond[i].second);
  if (x > 0 && y > 0) res = x + y;
  res = max(res, solve(coin, c_total));
  res = max(res, solve(diamond, d_total));
  cout << res << endl;
}
