#include <bits/stdc++.h>
using namespace std;
long long int pow(long long int x, long long int y, long long int m) {
  long long int res = 1;
  x = x % m;
  while (y > 0) {
    if (y & 1) res = ((res % m) * (x % m)) % m;
    y = y >> 1;
    x = ((x % m) * (x % m)) % m;
  }
  return res % m;
}
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
long long int clz(unsigned long long N) {
  return N ? 64LL - __builtin_clzll(N) : -INF;
}
clock_t time_p = clock();
void abhigyan10() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long int rnd(long long int l = 0, long long int r = INF) {
  return uniform_int_distribution<long long int>(l, r)(rng);
}
const long long int mod = 1000000007;
long long int modinv(long long int x) { return pow(x, mod - 2, mod); }
vector<pair<int, int>> C, D;
int bsC(int l, int h, int x) {
  int ans = -1, m;
  while (l <= h) {
    m = (h + l) / 2;
    if (C[m].first <= x) {
      ans = max(ans, C[m].second);
      l = m + 1;
    } else
      h = m - 1;
  }
  return ans;
}
int bsD(int l, int h, int x) {
  int ans = -1, m;
  while (l <= h) {
    m = (h + l) / 2;
    if (D[m].first <= x) {
      ans = max(ans, D[m].second);
      l = m + 1;
    } else
      h = m - 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, c, d, i, x, y;
  cin >> n >> c >> d;
  vector<pair<int, int>> a, b;
  char ch;
  for (i = 0; i < n; i++) {
    cin >> x >> y >> ch;
    if (ch == 'C')
      a.push_back({y, x});
    else
      b.push_back({y, x});
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int mx = 0;
  C.resize(a.size());
  D.resize(b.size());
  for (i = 0; i < (int)a.size(); i++) {
    C[i].first = a[i].first;
    if (mx < a[i].second) mx = a[i].second;
    C[i].second = mx;
  }
  mx = 0;
  for (i = 0; i < (int)b.size(); i++) {
    D[i].first = b[i].first;
    if (mx < b[i].second) mx = b[i].second;
    D[i].second = mx;
  }
  pair<int, int> temp = {0, 0};
  if (C.size() > 0) temp.first = bsC(0, (int)C.size() - 1, c);
  if (D.size() > 0) temp.second = bsD(0, (int)D.size() - 1, d);
  if (temp.first <= 0 || temp.second <= 0) temp = {0, 0};
  for (i = a.size() - 1; i > 0; i--) {
    if (a[i].first < c) {
      int se = bsC(0, i - 1, c - a[i].first);
      if (se > 0) {
        if (se + a[i].second > temp.first + temp.second)
          temp = {se, a[i].second};
      }
    }
  }
  for (i = b.size() - 1; i > 0; i--) {
    if (b[i].first < d) {
      int se = bsD(0, i - 1, d - b[i].first);
      if (se > 0) {
        if (se + b[i].second > temp.first + temp.second)
          temp = {se, b[i].second};
      }
    }
  }
  if (temp.first > 0 && temp.second > 0)
    cout << temp.first + temp.second;
  else
    cout << 0;
  return 0;
}
