#include <bits/stdc++.h>
using namespace std;
struct SegTree {
  vector<long long> tree;
  int n;
  SegTree(const vector<long long>& Arg) {
    n = Arg.size();
    tree.resize(2 * Arg.size());
    for (long long i = 0; i < n; i++) tree[n + i] = Arg[i];
    build();
  }
  void build() {
    for (int i = n - 1; i > 0; --i)
      tree[i] = max(tree[i << 1], tree[i << 1 | 1]);
  }
  void modify(int p, int value) {
    for (tree[p += n] = value; p > 1; p >>= 1)
      tree[p >> 1] = max(tree[p], tree[p ^ 1]);
  }
  long long query(int l, int r) {
    long long res = 0;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = max(res, tree[l++]);
      if (r & 1) res = max(res, tree[--r]);
    }
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  long long n, c, d;
  cin >> n >> c >> d;
  vector<long long> di(100010, 0), co(100010, 0), costc(100010, 200000),
      costd(100010, 200000);
  vector<multiset<long long> > diset(100010), coset(100010);
  for (int i = 0; i < n; i++) {
    long long b, p;
    char le;
    cin >> b >> p >> le;
    if (le == 'C') {
      co[p] = max(co[p], b);
      coset[p].insert(b);
      costc[b] = min(p, costc[b]);
    } else {
      di[p] = max(di[p], b);
      diset[p].insert(b);
      costd[b] = min(p, costd[b]);
    }
  }
  SegTree cot(co), dit(di);
  long long maxbeauty = 0;
  long long auxc = cot.query(0, c + 1), auxd = dit.query(0, d + 1);
  if (auxc > 0 and auxd > 0) maxbeauty = auxc + auxd;
  for (int i = 1; i <= c; i++) {
    long long aux1 = cot.query(0, i + 1);
    if (aux1 == 0) continue;
    long long m = costc[aux1];
    long long aux2;
    if (coset[m].count(aux1) > 1)
      aux2 = cot.query(0, c - m + 1);
    else {
      coset[m].erase(aux1);
      cot.modify(m, 0);
      if (coset[m].size() > 0) cot.modify(m, *(coset[m].rbegin()));
      aux2 = cot.query(0, c - m + 1);
      cot.modify(m, aux1);
      coset[m].insert(aux1);
    }
    if (aux1 > 0 and aux2 > 0) maxbeauty = max(maxbeauty, aux1 + aux2);
  }
  for (int i = 1; i <= d; i++) {
    long long aux1 = dit.query(0, i + 1);
    if (aux1 == 0) continue;
    long long m = costd[aux1];
    long long aux2;
    if (diset[m].count(aux1) > 1)
      aux2 = dit.query(0, d - m + 1);
    else {
      diset[m].erase(aux1);
      dit.modify(m, 0);
      if (diset[m].size() > 0) dit.modify(m, *(diset[m].rbegin()));
      aux2 = dit.query(0, d - m + 1);
      dit.modify(m, aux1);
      diset[m].insert(aux1);
    }
    if (aux1 > 0 and aux2 > 0) maxbeauty = max(maxbeauty, aux1 + aux2);
  }
  cout << maxbeauty << endl;
  return 0;
}
