#include <bits/stdc++.h>
using namespace std;
int betC[100001], betD[100001];
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, c, d;
  cin >> n >> c >> d;
  int a[n];
  vector<pair<int, int> > C, D;
  for (int i = 0; i < n; i++) {
    int x, y;
    char ch;
    cin >> x >> y >> ch;
    if (ch == 'C')
      C.push_back(pair<int, int>(x, y)), betC[y] = max(betC[y], x);
    else
      D.push_back(pair<int, int>(x, y)), betD[y] = max(betD[y], x);
  }
  for (int i = 1; i < 100001; i++)
    betC[i] = max(betC[i], betC[i - 1]), betD[i] = max(betD[i], betD[i - 1]);
  int ans = 0;
  sort(C.begin(), C.end());
  sort(D.begin(), D.end());
  if (C.size())
    for (int i = 0; i < C.size() - 1; i++)
      if (C[i].first == C[i + 1].first && C[i].second + C[i + 1].second <= c)
        ans = max(ans, C[i].first + C[i].first);
  if (D.size())
    for (int i = 0; i < D.size() - 1; i++)
      if (D[i].first == D[i + 1].first && D[i].second + D[i + 1].second <= d)
        ans = max(ans, D[i].first + D[i + 1].first);
  for (auto i : C) {
    int tmp = 0;
    if (i.second <= c) {
      int t = max(betC[min(c - i.second, i.second - 1)], betD[d]);
      tmp = i.first + t;
      if (t == 0) tmp = 0;
    }
    ans = max(ans, tmp);
  }
  for (auto i : D) {
    int tmp = 0;
    if (i.second <= d) {
      int t = max(betD[min(d - i.second, i.second - 1)], betC[c]);
      tmp = i.first + t;
      if (t == 0) tmp = 0;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
