#include <bits/stdc++.h>
using namespace std;
const int len = 1e5 + 5;
int b[len], val[len], tp[len];
struct node {
  int fi;
  int se;
} tree[2][4 * len];
node mer(node a, node b) {
  node ans;
  ans.fi = max(a.fi, b.fi);
  ans.se = max(min(a.fi, b.fi), max(a.se, b.se));
  return ans;
}
void update(int p, int l, int r, int i, int v, int s) {
  if (l == r) {
    if (v > tree[s][p].fi) {
      tree[s][p].se = tree[s][p].fi;
      tree[s][p].fi = v;
    } else if (v > tree[s][p].se && v <= tree[s][p].fi)
      tree[s][p].se = v;
  } else {
    int mid = (l + r) / 2;
    if (i <= mid)
      update(2 * p, l, mid, i, v, s);
    else
      update(2 * p + 1, mid + 1, r, i, v, s);
    tree[s][p] = mer(tree[s][2 * p], tree[s][2 * p + 1]);
  }
}
node query(int p, int l, int r, int i, int j, int s) {
  if (i <= l && r <= j) return tree[s][p];
  if (i > r || l > j) {
    node temp;
    temp.fi = temp.se = -1;
    return temp;
  }
  int mid = (l + r) / 2;
  node ans =
      mer(query(2 * p, l, mid, i, j, s), query(2 * p + 1, mid + 1, r, i, j, s));
  return ans;
}
int main() {
  int n, m, d;
  scanf("%d %d %d", &n, &m, &d);
  for (int i = 0; i < n; i++) {
    char temp;
    scanf("%d %d %c", &b[i], &val[i], &temp);
    tp[i] = temp - 'C';
    update(1, 0, len, val[i], b[i], tp[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if ((tp[i] == 0 && m >= val[i]) || (tp[i] == 1 && d >= val[i])) {
      int hey = m;
      if (tp[i] == 0) hey -= val[i];
      node temp = query(1, 0, len, 0, hey, 0);
      if (temp.fi == b[i] && tp[i] == 0 && val[i] <= hey)
        hey = temp.se;
      else
        hey = temp.fi;
      if (hey != 0) ans = max(hey + b[i], ans);
      hey = d;
      if (tp[i] == 1) hey -= val[i];
      temp = query(1, 0, len, 0, hey, 1);
      if (temp.fi == b[i] && tp[i] == 1 && val[i] <= hey)
        hey = temp.se;
      else
        hey = temp.fi;
      if (hey != 0) ans = max(ans, hey + b[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
