#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
  out << "{" << p.first << ", " << p.second << "} ";
  return out;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.fi > p.se;
  return in;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& arr) {
  for (auto& i : arr) in >> i;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& arr) {
  for (auto i : arr) out << i + 1 << " ";
  out << endl;
  return out;
}
const int64_t MAXN = 2e5 + 10;
vector<pair<int64_t, int64_t>> mon, diam;
int64_t n, c, d, t, t1;
int64_t b_ans = 0;
void read() {
  for (int64_t i(0); i < n; i++) {
    int64_t b, p;
    char c;
    cin >> b >> p >> c;
    if (c == 'D') {
      diam.push_back({p, b});
    } else {
      mon.push_back({p, b});
    }
  }
}
void fnd() {
  t = 0;
  t1 = 0;
  for (int64_t i(0); i < mon.size(); i++) {
    if (mon[i].first <= c) {
      t = max(t, mon[i].second);
    }
  }
  for (int64_t i(0); i < diam.size(); i++) {
    if (diam[i].first <= d) {
      t1 = max(t1, diam[i].second);
    }
  }
}
void solve(vector<pair<int64_t, int64_t>>& mon, int64_t kek) {
  multiset<int64_t> s;
  for (int64_t i(0); i < mon.size(); i++) {
    s.insert(mon[i].second);
  }
  int64_t pt = (int64_t)mon.size() - 1;
  for (int64_t i(0); i < mon.size() && mon[i].first <= kek; i++) {
    while (pt >= 0 && mon[pt].first > kek - mon[i].first) {
      s.erase(s.find(mon[pt].second));
      pt--;
    }
    if (pt >= i) {
      s.erase(s.find(mon[i].second));
    }
    if (s.size() != 0) {
      b_ans = max(b_ans, mon[i].second + *s.rbegin());
    }
    if (pt >= i) {
      s.insert(mon[i].second);
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n >> c >> d;
  read();
  sort(mon.begin(), mon.end());
  sort(diam.begin(), diam.end());
  fnd();
  if (t != 0 && t1 != 0) {
    b_ans = t + t1;
  }
  solve(mon, c);
  solve(diam, d);
  cout << b_ans << endl;
  return 0;
}
