#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int C[100002], D[100002], maxn = 100002;
int read(int *tree, int i) {
  int s = 0;
  while (i > 0) {
    s = max(s, tree[i]);
    i -= i & -i;
  }
  return s;
}
void add(int *tree, int i, int x) {
  while (i <= maxn) {
    tree[i] = max(tree[i], x);
    i += i & -i;
  }
}
int b, p;
char a;
int main() {
  int n, c, d, mm, ans = 0;
  cin >> n >> c >> d;
  for (int i = (0); i < (n); i++) {
    cin >> b >> p >> a;
    if (a == 'C') {
      mm = read(D, d);
      if (p > c) continue;
      mm = max(mm, read(C, c - p));
      add(C, p, b);
    } else {
      mm = read(C, c);
      if (p > d) continue;
      mm = max(mm, read(D, d - p));
      add(D, p, b);
    }
    if (mm) {
      ans = max(ans, mm + b);
    }
  }
  cout << ans << endl;
}
