#include <bits/stdc++.h>
using namespace std;
int b[100200];
int p[100200];
char t[100200];
int id[100200];
vector<pair<int, int> > s1, s2;
struct ST {
  int n;
  int *t;
  void build(int N, vector<pair<int, int> > &v) {
    n = 1;
    while (n < N) {
      n <<= 1;
    }
    t = new int[2 * n]();
    for (int i = 0; i < 2 * n; i++) {
      t[i] = -1000000008;
    }
    for (int i = 0; i < v.size(); i++) {
      t[i + n] = v[i].second;
    }
    for (int i = n - 1; i > 0; i--) {
      t[i] = max(t[i << 1], t[(i << 1) + 1]);
    }
  }
  int get(int v, int l, int r, int tl, int tr) {
    if (r < tl || tr < l) {
      return -1000000008;
    }
    if (l <= tl && tr <= r) {
      return t[v];
    }
    int tm = (tl + tr) >> 1;
    return max(get(v << 1, l, r, tl, tm), get((v << 1) + 1, l, r, tm + 1, tr));
  }
  void upd(int v, int l, int r, int val, int tl, int tr) {
    if (r < tl || l > tr) return;
    if (l <= tl && tr <= r) {
      t[v] = val;
      return;
    }
    int tm = (tl + tr) >> 1;
    upd(v << 1, l, r, val, tl, tm);
    upd((v << 1) + 1, l, r, val, tm + 1, tr);
    t[v] = max(t[v << 1], t[(v << 1) + 1]);
  }
};
ST S1, S2;
int go(vector<pair<int, int> > &v, int pr, int bt) {
  pair<int, int> val = pair<int, int>(pr, bt);
  int l = 0, r = (int)v.size() - 1;
  while (l < r) {
    int m = (r + l) / 2;
    if (v[m] < val) {
      l = m + 1;
    } else
      r = m;
  }
  return l;
}
int solve(int coins, int diam) {
  if (coins < 0 || diam < 0) return -1000000008;
  int res1 = -1000000008, res2 = -1000000008;
  int l = 0, r = (int)s1.size() - 1;
  while (l < r) {
    int m = (r + l + 1) / 2;
    if (s1[m].first > coins) {
      r = m - 1;
    } else
      l = m;
  }
  if (s1.empty() || r >= 0 && s1[0].first > coins) {
  } else
    res1 = S1.get(1, 0, r, 0, S1.n - 1);
  l = 0, r = (int)s2.size() - 1;
  while (l < r) {
    int m = (r + l + 1) / 2;
    if (s2[m].first > diam) {
      r = m - 1;
    } else
      l = m;
  }
  if (s2.empty() || r >= 0 && s2[0].first > diam) {
  } else
    res2 = S2.get(1, 0, r, 0, S2.n - 1);
  return max(res1, res2);
}
int main() {
  int n, c, d;
  scanf("%d %d %d", &n, &c, &d);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &b[i], &p[i]);
    scanf(" %c", &t[i]);
    if (t[i] == 'C') {
      s1.push_back(pair<int, int>(p[i], b[i]));
    } else {
      s2.push_back(pair<int, int>(p[i], b[i]));
    }
  }
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  S1.build(s1.size(), s1);
  S2.build(s2.size(), s2);
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (t[i] == 'C') {
      int tmp = go(s1, p[i], b[i]);
      S1.upd(1, tmp, tmp, -1000000008, 0, S1.n - 1);
      res = max(res, b[i] + solve(c - p[i], d));
      S1.upd(1, tmp, tmp, b[i], 0, S1.n - 1);
    } else {
      int tmp = go(s2, p[i], b[i]);
      S2.upd(1, tmp, tmp, -1000000008, 0, S2.n - 1);
      res = max(res, b[i] + solve(c, d - p[i]));
      S2.upd(1, tmp, tmp, b[i], 0, S2.n - 1);
    }
  }
  printf("%d\n", res);
  return 0;
}
