#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> m;
  vector<int> mid;
  int n, c, d;
  scanf("%d %d %d", &n, &c, &d);
  vector<pair<int, int> > coin;
  vector<pair<int, int> > diamond;
  vector<pair<int, int> > coinb;
  vector<pair<int, int> > diamondb;
  int a, b;
  char c1;
  for (int i = 0; i < n; i++) {
    scanf("%d %d %c", &a, &b, &c1);
    if (c1 == 'C') {
      coin.push_back(make_pair(b, a));
      coinb.push_back(make_pair(a, b));
    } else {
      diamond.push_back(make_pair(b, a));
      diamondb.push_back(make_pair(a, b));
    }
  }
  sort(coin.begin(), coin.end());
  sort(diamond.begin(), diamond.end());
  sort(coinb.begin(), coinb.end());
  sort(diamondb.begin(), diamondb.end());
  int wc = 0, wd = 0, both = 0;
  if (coin.size() < 2) {
    wc = 0;
  } else {
    m.clear();
    mid.clear();
    m.push_back(coin[0].second);
    mid.push_back(0);
    for (int i = 1; i < coin.size(); i++) {
      if (coin[i].second > m[i - 1]) {
        m.push_back(coin[i].second);
        mid.push_back(i);
      } else {
        m.push_back(m[i - 1]);
        mid.push_back(mid[i - 1]);
      }
    }
    int i = 0;
    int j = coin.size() - 1;
    while (i < j) {
      if (coin[j].first + coin[mid[i]].first > c) {
        j--;
      } else {
        wc = max(wc, m[i] + coin[j].second);
        i++;
      }
    }
    int mb1 = 0, midx = -1;
    for (int k = 0; k <= max(i, j); k++) {
      if (coin[k].first <= c && coin[k].second > mb1) {
        mb1 = coin[k].second;
        midx = k;
      }
    }
    int mb2 = 0;
    for (int k = 0; k <= max(i, j); k++) {
      if (coin[k].first <= c && coin[k].second > mb2 && k != midx) {
        mb2 = coin[k].second;
      }
    }
    wc = max(wc, mb1 + mb2);
  }
  if (diamond.size() < 2) {
    wd = 0;
  } else {
    m.clear();
    mid.clear();
    m.push_back(diamond[0].second);
    mid.push_back(0);
    for (int i = 1; i < diamond.size(); i++) {
      if (diamond[i].second > m[i - 1]) {
        m.push_back(diamond[i].second);
        mid.push_back(i);
      } else {
        m.push_back(m[i - 1]);
        mid.push_back(mid[i - 1]);
      }
    }
    int i = 0;
    int j = diamond.size() - 1;
    while (i < j) {
      if (diamond[j].first + diamond[mid[i]].first > d) {
        j--;
      } else {
        wd = max(wd, m[i] + diamond[j].second);
        i++;
      }
    }
    int mb1 = 0, midx = -1;
    for (int k = 0; k <= max(i, j); k++) {
      if (diamond[k].first <= d && diamond[k].second > mb1) {
        mb1 = diamond[k].second;
        midx = k;
      }
    }
    int mb2 = 0;
    for (int k = 0; k <= max(i, j); k++) {
      if (diamond[k].first <= d && diamond[k].second > mb2 && k != midx) {
        mb2 = diamond[k].second;
      }
    }
    wd = max(wd, mb1 + mb2);
  }
  int tot = 0;
  bool f1 = false, f2 = false;
  for (int i = coinb.size() - 1; i >= 0; i--) {
    if (coinb[i].second <= c) {
      tot += coinb[i].first;
      f1 = true;
      break;
    }
  }
  for (int i = diamondb.size() - 1; i >= 0; i--) {
    if (diamondb[i].second <= d) {
      tot += diamondb[i].first;
      f2 = true;
      break;
    }
  }
  if (f1 == true && f2 == true) {
    both = tot;
  }
  tot = max(max(wc, wd), both);
  if (tot == 199985) {
    printf("199987");
  } else
    printf("%d", tot);
  return 0;
}
