#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
const double sn = 1e-9;
const long double PI = 3.141592653589793238L;
int n, c, d;
int mc[100005];
int md[100005];
vector<pair<int, int>> ac;
vector<pair<int, int>> ad;
bool cmp(pair<int, int> p1, pair<int, int> p2) { return p1.first > p2.first; }
int check(int l, int r, vector<pair<int, int>> &arr, int v) {
  while (l != r) {
    int mid = (l + r) / 2;
    if (arr[mid].first <= v)
      r = mid;
    else
      l = mid + 1;
  }
  return l;
}
int main() {
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 0; i < n; i++) {
    int b, p;
    char t[5];
    scanf("%d%d%s", &b, &p, t);
    if (t[0] == 'C') {
      ac.push_back(make_pair(p, b));
    } else {
      ad.push_back(make_pair(p, b));
    }
  }
  sort(ac.begin(), ac.end(), cmp);
  sort(ad.begin(), ad.end(), cmp);
  int sz1 = ac.size(), sz2 = ad.size();
  if (sz1 != 0) {
    mc[sz1 - 1] = ac[sz1 - 1].second;
    for (int i = sz1 - 2; i >= 0; i--) mc[i] = max(ac[i].second, mc[i + 1]);
  }
  if (sz2 != 0) {
    md[sz2 - 1] = ad[sz2 - 1].second;
    for (int i = sz2 - 2; i >= 0; i--) md[i] = max(ad[i].second, md[i + 1]);
  }
  int abc = check(0, sz1, ac, c), abd = check(0, sz2, ad, d);
  int mh = INT_MIN;
  if (abc != sz1 && abd != sz2) {
    mh = max(mh, mc[abc] + md[abd]);
  }
  for (int i = 0; i < sz1; i++) {
    if (ac[i].first > c) continue;
    int v = check(i + 1, sz1, ac, c - ac[i].first);
    if (v != sz1) {
      mh = max(mh, mc[v] + ac[i].second);
    }
  }
  for (int i = 0; i < sz2; i++) {
    if (ad[i].first > d) continue;
    int v = check(i + 1, sz2, ad, d - ad[i].first);
    if (v != sz2) {
      mh = max(mh, md[v] + ad[i].second);
    }
  }
  printf("%d\n", max(mh, 0));
  return 0;
}
