#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 100000;
const int kMaxB = 100000;
struct Fontain {
  Fontain() = default;
  Fontain(int cost, int beauty, int index)
      : m_cost(cost), m_beauty(beauty), m_index(index) {}
  bool operator<(Fontain const &rhs) const {
    if (m_cost != rhs.m_cost) return m_cost < rhs.m_cost;
    if (m_beauty != rhs.m_beauty) return m_beauty < rhs.m_beauty;
    return m_index < rhs.m_index;
  }
  int m_cost = 0;
  int m_beauty = 0;
  int m_index = 0;
};
vector<Fontain> g_coins;
vector<Fontain> g_diamonds;
int GetBest(int budget, vector<Fontain> const &fontains) {
  int best = 0;
  for (auto const &f : fontains) {
    if (f.m_cost <= budget && f.m_beauty > best) best = f.m_beauty;
  }
  return best;
}
int BestDifferent(int c, int d, vector<Fontain> const &coins,
                  vector<Fontain> const &diamonds) {
  int const bestC = GetBest(c, coins);
  int const bestD = GetBest(d, diamonds);
  return bestC == 0 || bestD == 0 ? 0 : bestC + bestD;
}
int BestSame(int budget, vector<Fontain> const &fontains) {
  vector<int> prefixMax(fontains.size() + 1);
  for (int i = 0; i < fontains.size(); ++i)
    prefixMax[i + 1] = max(prefixMax[i], fontains[i].m_beauty);
  int best = 0;
  for (int i = 0; i < fontains.size(); ++i) {
    if (fontains[i].m_cost > budget) break;
    int const allowed = min(fontains[i].m_cost, budget - fontains[i].m_cost);
    auto const it = upper_bound(fontains.begin(), fontains.end(),
                                Fontain(allowed, kMaxB * 2, kMaxN * 2));
    int n = distance(fontains.begin(), it);
    n = min(n, i);
    if (prefixMax[n] != 0 && prefixMax[n] + fontains[i].m_beauty > best)
      best = prefixMax[n] + fontains[i].m_beauty;
  }
  return best;
}
int main() {
  char type[8];
  int n, c, d;
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 0; i < n; ++i) {
    int b, p;
    scanf("%d%d%s", &b, &p, type);
    if (type[0] == 'C')
      g_coins.emplace_back(p, b, i);
    else
      g_diamonds.emplace_back(p, b, i);
  }
  sort(g_coins.begin(), g_coins.end());
  sort(g_diamonds.begin(), g_diamonds.end());
  int const bestDifferent = BestDifferent(c, d, g_coins, g_diamonds);
  int const bestCoins = BestSame(c, g_coins);
  int const bestDiamonds = BestSame(d, g_diamonds);
  printf("%d\n", max(bestDifferent, max(bestCoins, bestDiamonds)));
  return 0;
}
