#include <bits/stdc++.h>
using namespace std;
int n, c, d;
vector<pair<int, int> > a;
vector<pair<int, int> > b;
int q1[110000];
int q2[110000];
int mval(const vector<pair<int, int> > &x) {
  int res = x[0].second;
  for (int i = 1; i < x.size(); ++i) res = max(res, x[i].second);
  return res;
}
int solve(const vector<pair<int, int> > &x, int n) {
  q1[0] = x[0].second;
  q2[0] = -1;
  for (int i = 1; i < x.size(); ++i) {
    int cur = x[i].second;
    if (cur > q1[i - 1]) {
      q1[i] = cur;
      q2[i] = q1[i - 1];
    } else if (cur > q2[i - 1]) {
      q1[i] = q1[i - 1];
      q2[i] = cur;
    } else {
      q1[i] = q1[i - 1];
      q2[i] = q2[i - 1];
    }
  }
  int p = x.size() - 1;
  int res = 0;
  for (int i = 0; i < x.size(); ++i) {
    while (p >= 0 && n - x[i].first < x[p].first) p--;
    if (p < 0) break;
    int cur = q1[p];
    if (cur == x[i].second) cur = q2[p];
    if (cur > 0) res = max(res, x[i].second + cur);
  }
  return res;
}
int main() {
  cin.tie();
  ios::sync_with_stdio(0);
  cin >> n >> c >> d;
  for (int i = 0; i < n; ++i) {
    int x, y;
    char c1;
    cin >> x >> y >> c1;
    if (c1 == 'C' && y <= c) a.push_back(make_pair(y, x));
    if (c1 == 'D' && y <= d) b.push_back(make_pair(y, x));
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int ans = 0;
  if (a.size() > 0 && b.size() > 0) ans = mval(a) + mval(b);
  if (a.size() > 1) ans = max(ans, solve(a, c));
  if (b.size() > 1) ans = max(ans, solve(b, d));
  cout << ans << "\n";
}
