#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e6 + 4;
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res % MOD;
}
int gcd(int a, int b) {
  while (b > 0) {
    int t = a % b;
    a = b, b = t;
  }
  return a;
}
int lcm(int a, int b) { return (a / gcd(a, b)) * b; }
int is_prime(int n) {
  if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0)) return 0;
  for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
    if (n % i == 0) return 0;
  return 1;
}
int modI(int a, int m) {
  int m0 = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    int q = a / m;
    int t = m;
    m = a % m;
    a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long mod_inv(long long a, long long m = MOD) {
  return a == 1 ? 1 : m - mod_inv(m % a, a) * m / a;
}
long long choose(long long n, long long r) {
  long long product = 1;
  for (long long i = 0; i < r; i++)
    product = product * (n - i) % MOD * mod_inv(i + 1) % MOD;
  return product;
}
long long getcount(long long n, int k) {
  long long res = (n >> (k + 1)) << k;
  if ((n >> k) & 1) res += n & ((1ll << k) - 1);
  return res;
}
int bit[N];
void init(void) {
  int i;
  for (int i = 0; i < N; i++) bit[i] = 0;
}
void update(int idx, int val) {
  while (idx <= N) {
    bit[idx] = max(bit[idx], val);
    idx += idx & -idx;
  }
}
int pref(int idx) {
  int ans = 0;
  while (idx > 0) {
    ans = max(ans, bit[idx]);
    idx -= idx & -idx;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, c, d;
  long long ma = 0, mi = 0;
  cin >> n >> c >> d;
  vector<pair<long long, long long>> x, y;
  for (int i = 0; i < n; i++) {
    long long a, b;
    char ca;
    cin >> a >> b >> ca;
    if (ca == 'C') {
      if (b <= c) ma = max(ma, a);
      x.push_back({b, a});
    } else {
      if (b <= d) mi = max(mi, a);
      y.push_back(make_pair(b, a));
    }
  }
  long long ans = 0;
  int l = 0;
  for (int i = 0; i < x.size(); i++) {
    if (c >= x[i].first) {
      if (pref(c - x[i].first) > 0) {
        l = 1;
        ans = max(ans, x[i].second + pref(c - x[i].first));
      }
      update(x[i].first, x[i].second);
    }
  }
  init();
  for (int i = 0; i < y.size(); i++) {
    if (d >= y[i].first) {
      if (pref(d - y[i].first) > 0) {
        l = 1;
        ans = max(ans, y[i].second + pref(d - y[i].first));
      }
      update(y[i].first, y[i].second);
    }
  }
  if (min(mi, ma) > 0) ans = max(ans, ma + mi);
  if (l == 1 || min(ma, mi) > 0)
    cout << ans << "\n";
  else
    cout << 0 << "\n";
  return 0;
}
