#include <bits/stdc++.h>
using namespace std;
const long long int N = 3e5 + 2, inf = 1e9 + 7;
void _run();
void no() { cout << "-1\n", exit(0); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  _run();
  return 0;
}
vector<pair<int, int> > C, D;
int T[N];
void build(int nod, int lo, int hi) {
  if (lo == hi) {
    T[nod] = C[lo - 1].second;
    return;
  }
  int md = (lo + hi) >> 1;
  build(2 * nod, lo, md);
  build(2 * nod + 1, md + 1, hi);
  T[nod] = max(T[2 * nod], T[2 * nod + 1]);
}
int qry(int nod, int lo, int hi, int l, int r) {
  if (hi < l || lo > r || lo > hi) return 0;
  if (lo >= l && hi <= r) return T[nod];
  int md = (lo + hi) >> 1;
  return max(qry(2 * nod, lo, md, l, r), qry(2 * nod + 1, md + 1, hi, l, r));
}
void _run() {
  int n, c, d;
  cin >> n >> c >> d;
  for (int i = 1; i <= n; i++) {
    int b, p;
    string s;
    cin >> b >> p >> s;
    if (s[0] == 'C')
      C.push_back(make_pair(p, b));
    else
      D.push_back(make_pair(p, b));
  }
  sort(C.begin(), C.end());
  sort(D.begin(), D.end());
  int rs = 0;
  int a = 0, b = 0;
  for (auto x : C) {
    if (x.first <= c) a = max(a, x.second);
  }
  for (auto x : D) {
    if (x.first <= d) b = max(b, x.second);
  }
  rs = a + b;
  int i = 0;
  if (a == 0 || b == 0) rs = 0;
  if ((int)C.size() != 0) build(1, 1, (int)C.size());
  for (auto x : C) {
    i++;
    if (x.first > c) continue;
    int lo = i + 1, hi = (int)C.size(), md, cur = -1;
    while (lo <= hi) {
      md = (lo + hi) >> 1;
      if (C[md - 1].first > c - x.first)
        hi = md - 1;
      else
        lo = md + 1, cur = md;
    }
    if (cur == -1) continue;
    cur--;
    if (C[cur].first <= c - x.first) {
      int rt = qry(1, 1, (int)C.size(), i + 1, cur + 1);
      rs = max(rs, rt + x.second);
    }
  }
  C.clear();
  C = D;
  c = d;
  i = 0;
  if ((int)C.size() != 0) build(1, 1, (int)C.size());
  for (auto x : C) {
    i++;
    if (x.first > c) continue;
    int lo = i + 1, hi = (int)C.size(), md, cur = -1;
    while (lo <= hi) {
      md = (lo + hi) >> 1;
      if (C[md - 1].first > c - x.first)
        hi = md - 1;
      else
        lo = md + 1, cur = md;
    }
    if (cur == -1) continue;
    cur--;
    if (C[cur].first <= c - x.first) {
      int rt = qry(1, 1, (int)C.size(), i + 1, cur + 1);
      rs = max(rs, rt + x.second);
    }
  }
  cout << rs << "\n";
}
