#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6 + 9;
const long long int mod = 1e9 + 7;
vector<pair<long long int, long long int>> v, u;
long long int test(vector<pair<long long int, long long int>> v,
                   long long int cost) {
  long long int mm = 0;
  long long int n = v.size();
  if (!n) return 0;
  long long int maxm[n], a[n];
  maxm[0] = v[0].second;
  for (int i = 1; i <= n - 1; i++) {
    maxm[i] = max(maxm[i - 1], v[i].second);
  }
  for (int i = 0; i <= n - 1; i++) a[i] = v[i].first;
  for (int i = n - 1; i >= 0; i--) {
    long long int d = upper_bound(a, a + n, cost - (v[i].first)) - a;
    d--;
    if (d >= i) d = i - 1;
    if (d < 0) continue;
    if (mm < maxm[d] + v[i].second) mm = maxm[d] + v[i].second;
  }
  return mm;
}
void solve() {
  long long int n, c, d, maxc = 0, maxd = 0;
  cin >> n >> c >> d;
  for (int i = 1; i <= n; i++) {
    long long int x, y;
    char ch;
    cin >> x >> y >> ch;
    if (ch == 'C') {
      if (y <= c) {
        v.push_back({y, x});
        if (maxc < x) maxc = x;
      }
    } else {
      if (y <= d) {
        u.push_back({y, x});
        if (maxd < x) maxd = x;
      }
    }
  }
  sort(v.begin(), v.end());
  sort(u.begin(), u.end());
  long long int res1 = test(v, c);
  long long int res2 = test(u, d);
  if (maxc == 0) maxd = 0;
  if (maxd == 0) maxc = 0;
  cout << max(maxc + maxd, max(res1, res2));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) solve();
}
