#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

const int VERBOSE = 0;

int n, p, k;
vector<long long> D;
long long answer;

long long solve() {
    for (int z=0; z+p<=n; ++z) {
        vector<long long> usek( D.begin()+z, D.begin()+z+p );
        sort( usek.begin(), usek.end() );
        long long curr = 0;
        int eaten = 0;
        for (int i=0; i<p; ++i) {
            if (i < k && usek[i] < 0) { ++eaten; curr -= usek[i]; } else curr += usek[i];
        }
        if (curr >= answer) {
            if (VERBOSE) cerr << "new max " << curr << " at start " << z << " after eating " << eaten << " negatives" << endl;
            answer = curr;
        }
    }
    return answer;
}

int main() {
    cin >> n >> p >> k;
    D.resize(n);
    for (int i=0; i<n; ++i) {
        string smer;
        cin >> smer >> D[i];
        if (smer == "Z") D[i] *= -1;
    }
    answer = 0;
    solve();
    for (auto &d : D) d = -d;
    solve();
    cout << answer << endl;
}
