#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int solve(vector<pair<int, int>> v, int w) {
  vector<int> t({INT_MIN});
  int mx = INT_MIN;
  sort(v.begin(), v.end());
  for (auto e : v) {
    mx = max(mx, e.second);
    t.push_back(mx);
  }
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    int x = upper_bound(v.begin(), v.end(),
                        pair<int, int>(w - v[i].first, INT_MAX)) -
            v.begin();
    x = min(x, i);
    ans = max(ans, v[i].second + t[x]);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, c, d;
  cin >> n >> c >> d;
  vector<pair<int, int>> a, b;
  for (int i = 0; i < n; i++) {
    int x, c;
    char type;
    cin >> x >> c >> type;
    if (type == 'C')
      a.push_back({c, x});
    else
      b.push_back({c, x});
  }
  int b1 = INT_MIN, b2 = INT_MIN;
  for (auto e : a) {
    if (e.first <= c) b1 = max(b1, e.second);
  }
  for (auto e : b) {
    if (e.first <= d) b2 = max(b2, e.second);
  }
  int ans = b1 + b2;
  ans = max(ans, solve(a, c));
  ans = max(ans, solve(b, d));
  ans = max(ans, 0);
  cout << ans;
}
