#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[200020], b[200020];
int x, y, c, d;
int n;
int mx[200020];
int calc(pair<int, int> a[], int len, int val) {
  for (int i = 1; i <= len; ++i) {
    mx[i] = max(mx[i - 1], a[i].second);
  }
  int ret = 0;
  for (int i = len, j = 1; i >= 1; --i) {
    while (j <= len && a[j].first + a[i].first <= val) {
      ++j;
    }
    if (j > 1 && i > 1) ret = max(ret, a[i].second + mx[min(j - 1, i - 1)]);
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    int u, v;
    char op[5];
    scanf("%d%d%s", &u, &v, op);
    if (op[0] == 'C')
      a[++x] = make_pair(v, u);
    else
      b[++y] = make_pair(v, u);
  }
  sort(a + 1, a + x + 1);
  sort(b + 1, b + y + 1);
  int ans = calc(a, x, c);
  ans = max(ans, calc(b, y, d));
  int mx1 = -1, mx2 = -1;
  for (int i = 1; i <= x; ++i)
    if (a[i].first <= c) mx1 = max(mx1, a[i].second);
  for (int i = 1; i <= y; ++i)
    if (b[i].first <= d) mx2 = max(mx2, b[i].second);
  if (mx1 != -1 && mx2 != -1) ans = max(ans, mx1 + mx2);
  printf("%d\n", ans);
  return 0;
}
