#include <bits/stdc++.h>
using namespace std;
const auto infinity = numeric_limits<int>::max();
struct FenwickTree {
  int N;
  vector<int> data;
  FenwickTree(const int N) : N(N), data(N + 1, -infinity) {}
  void update(const int n, const int x) {
    for (auto i = n; i <= N; i += i & -i) data[i] = max(data[i], x);
  }
  int query(const int n) {
    auto result = -infinity;
    for (auto i = n; i >= 1; i -= i & -i) result = max(result, data[i]);
    return result;
  }
};
int main() {
  int n, c, d;
  cin >> n >> c >> d;
  auto coin = FenwickTree(1e5);
  auto diamond = FenwickTree(1e5);
  auto result = 0;
  for (auto i = 0; i < n; i++) {
    int beauty, price;
    char type;
    cin >> beauty >> price >> type;
    if (type == 'C' && price <= c) {
      result = max(result, beauty + coin.query(c - price));
      result = max(result, beauty + diamond.query(d));
      coin.update(price, beauty);
    }
    if (type == 'D' && price <= d) {
      result = max(result, beauty + diamond.query(d - price));
      result = max(result, beauty + coin.query(c));
      diamond.update(price, beauty);
    }
  }
  cout << result << endl;
}
