#include <bits/stdc++.h>
using namespace std;
struct Fountain {
  int m_cost;
  int m_beauty;
};
int num, diamonds, coins, maxbeauty, cost, beauty, cf, df, max1, max2, nzv;
char costtype;
int maxb[100000];
vector<Fountain> dfountains(100000);
vector<Fountain> cfountains(100000);
bool compare(Fountain &f1, Fountain &f2) { return f1.m_cost < f2.m_cost; }
int solve(vector<Fountain> &info, int kash, int n) {
  sort(info.begin(), info.begin() + n, compare);
  int i = 0, answer = 0, x;
  maxb[0] = info[0].m_beauty;
  for (int m = 0; m < n; ++m) {
    maxb[m + 1] = max(maxb[m], info[m].m_beauty);
  }
  for (int j = n - 1; j >= 0; --j) {
    x = info[i].m_cost + info[j].m_cost;
    while (i < j && info[i].m_cost + info[j].m_cost <= kash) {
      ++i;
      x = info[i].m_cost + info[j].m_cost;
    }
    i = min(i, j);
    if (i > 0) {
      answer = max(answer, maxb[i] + info[j].m_beauty);
    }
  }
  return answer;
}
int main() {
  cin >> num >> coins >> diamonds;
  max1 = 0;
  max2 = 0;
  maxbeauty = 0;
  for (int a = 0; a < num; ++a) {
    cin >> beauty >> cost >> costtype;
    if (costtype == 'C' && cost <= coins) {
      cfountains[cf].m_beauty = beauty;
      cfountains[cf].m_cost = cost;
      ++cf;
    } else if (cost <= diamonds && costtype == 'D') {
      dfountains[df].m_beauty = beauty;
      dfountains[df].m_cost = cost;
      ++df;
    }
  }
  if (cf >= 1 && df >= 1) {
    for (int a = 0; a < cf; ++a) {
      if (cfountains[a].m_beauty > max1) {
        max1 = cfountains[a].m_beauty;
      }
    }
    for (int a = 0; a < df; ++a) {
      if (dfountains[a].m_beauty > max2) {
        max2 = dfountains[a].m_beauty;
      }
    }
    if (max1 + max2 > maxbeauty) {
      maxbeauty = max1 + max2;
    }
  }
  if (cf > 1) {
    maxbeauty = max(solve(cfountains, coins, cf), maxbeauty);
  }
  if (df > 1) {
    maxbeauty = max(solve(dfountains, diamonds, df), maxbeauty);
  }
  cout << maxbeauty << endl;
  return 0;
}
