#include <bits/stdc++.h>
#pragma pack(1)
using namespace std;
template <typename T>
T sqr(T first) {
  return first * first;
}
const long long md = 1e9 + 7;
const long long md2 = 2e9 + 7;
const int MAXN = 2e6 + 1;
const int MAXLOG = 45;
const long double PI = acos(-1);
const int INF = 1e9 + 1;
const pair<int, int> turns[4] = {{1, 0}, {0, -1}, {0, 1}, {-1, 0}};
const char signs[4] = {'D', 'L', 'R', 'U'};
int n, c[2];
pair<int, int> a[2][MAXN];
int sz[2];
int t[MAXN];
multiset<int> st[MAXN];
void upd(int v, int l, int r, int pos, int type, int val) {
  if (l == r) {
    if (type) {
      st[l].insert(val);
    } else {
      st[l].erase(st[l].find(val));
    }
    t[v] = (st[l].empty() ? 0 : *st[l].rbegin());
  } else {
    int m = (l + r) / 2;
    if (pos <= m) {
      upd(2 * v, l, m, pos, type, val);
    } else {
      upd(2 * v + 1, m + 1, r, pos, type, val);
    }
    t[v] = max(t[2 * v], t[2 * v + 1]);
  }
}
int get(int v, int l, int r, int L, int R) {
  if (L <= l && r <= R) return t[v];
  if (r < L || R < l || R < L) return 0;
  int m = (l + r) / 2;
  return max(get(2 * v, l, m, L, R), get(2 * v + 1, m + 1, r, L, R));
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> c[0] >> c[1];
  for (int i = 1; i <= n; i++) {
    int B, P;
    char c;
    cin >> B >> P >> c;
    if (c == 'C') {
      a[0][sz[0]++] = make_pair(P, B);
    } else {
      a[1][sz[1]++] = make_pair(P, B);
    }
  }
  int ans = 0;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < sz[i]; j++) {
      upd(1, 1, 100000, a[i][j].first, 1, a[i][j].second);
    }
    for (int j = 0; j < sz[i]; j++) {
      upd(1, 1, 100000, a[i][j].first, 0, a[i][j].second);
      int g = get(1, 1, 100000, 1, c[i] - a[i][j].first);
      if (g != 0) ans = max(ans, a[i][j].second + g);
      upd(1, 1, 100000, a[i][j].first, 1, a[i][j].second);
    }
    for (int j = 0; j < sz[i]; j++) {
      upd(1, 1, 100000, a[i][j].first, 0, a[i][j].second);
    }
  }
  int cur = 0, cc = 1;
  for (int i = 0; i < 2; i++) {
    int mx = 0;
    for (int j = 0; j < sz[i]; j++) {
      if (a[i][j].first <= c[i]) {
        mx = max(mx, a[i][j].second);
      }
    }
    if (mx != 0)
      cur += mx;
    else
      cc = 0;
  }
  cout << max(ans, cur * cc);
}
