#include <bits/stdc++.h>
using namespace std;
int Log[100010];
class fountain {
 public:
  int beauty;
  int cost;
  char type;
};
fountain a[100010];
void getlog(int m) {
  int i;
  Log[1] = 0;
  for (i = 2; i < m; i++) {
    Log[i] = Log[i / 2] + 1;
  }
}
int n, c, d, b, cost, cnt, maxs;
char type;
struct node {
  int b, cost;
  char type;
};
node f[100010];
bool cmp(node x, node y) {
  if (x.b != y.b)
    return x.b > y.b;
  else {
    return x.cost < y.cost;
  }
}
int main() {
  while (scanf("%d%d%d", &n, &c, &d) != EOF) {
    maxs = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d%d %c", &b, &cost, &type);
      f[i].b = b;
      f[i].cost = cost;
      f[i].type = type;
    }
    sort(f, f + n, cmp);
    int max1 = 0, max2 = 0;
    for (int i = 0; i < n; i++) {
      if (f[i].type == 'C' && f[i].cost <= c) {
        max1 = f[i].b;
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      if (f[i].type == 'D' && f[i].cost <= d) {
        max2 = f[i].b;
        break;
      }
    }
    int maxxn = 0;
    if (max1 != 0 && max2 != 0) {
      maxxn = max1 + max2;
    }
    for (int i = 0; i < n; i++) {
      int t1 = c;
      int t2 = d;
      if (f[i].type == 'C' && t1 <= f[i].cost)
        continue;
      else if (f[i].type == 'D' && t2 <= f[i].cost)
        continue;
      if (f[i].type == 'C' && t1 > f[i].cost) {
        t1 -= f[i].cost;
        cnt = 0;
        cnt += f[i].b;
      } else if (f[i].type == 'D' && t2 > f[i].cost) {
        t2 -= f[i].cost;
        cnt = 0;
        cnt += f[i].b;
      }
      for (int j = i + 1; j < n; j++) {
        if (f[j].type == 'C' && f[j].cost <= t1) {
          cnt += f[j].b;
          maxs = max(maxs, cnt);
          break;
        } else if (f[j].type == 'D' && f[j].cost <= t2) {
          cnt += f[j].b;
          maxs = max(maxs, cnt);
          break;
        }
      }
    }
    printf("%d\n", max(maxs, maxxn));
  }
  return 0;
}
