#include <bits/stdc++.h>
std::pair<int, int> v[100009], u[100009];
int bestx[100009], besty[100009];
inline int sol(std::pair<int, int> a[], int n, int lim, int r[]) {
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    int rez = 0;
    for (int pas = 1 << 16; pas; pas >>= 1)
      if ((rez + pas < i) && (a[rez + pas].first + a[i].first <= lim))
        rez += pas;
    if (rez > 0) ans = std::max(ans, r[rez] + a[i].second);
  }
  return ans;
}
int main() {
  int n, c, d;
  fscanf(stdin, "%d%d%d", &n, &c, &d);
  int k = 0, m = 0;
  for (int i = 1; i <= n; i++) {
    int first, second;
    char ch;
    fscanf(stdin, "%d%d %c", &first, &second, &ch);
    if (ch == 'D') {
      if (second <= d) {
        v[++k].first = second;
        v[k].second = first;
      }
    } else {
      if (second <= c) {
        u[++m].first = second;
        u[m].second = first;
      }
    }
  }
  int ans = 0;
  std::sort(v + 1, v + k + 1);
  std::sort(u + 1, u + m + 1);
  for (int i = 1; i <= k; i++) bestx[i] = std::max(bestx[i - 1], v[i].second);
  for (int i = 1; i <= m; i++) besty[i] = std::max(besty[i - 1], u[i].second);
  if ((k > 0) && (m > 0)) ans = bestx[k] + besty[m];
  if (k >= 2) ans = std::max(ans, sol(v, k, d, bestx));
  if (m >= 2) ans = std::max(ans, sol(u, m, c, besty));
  fprintf(stdout, "%d\n", ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
