#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|

string S;
ll N,Q;

ll solve(ll k){
    ll ret = 0;
    ll d = 0;
    ll m = 0;
    ll dm = 0;
    REP(i,k){
        if (S[i] == 'D') d++;
        if (S[i] == 'M') {
            m++;
            dm += d;
        }
        if (S[i] == 'C'){
            ret += dm;
        }
    }

    for (size_t i = k; i < N; i++) {
        char prev = S[i-k];
        char next = S[i];
        if (prev == 'D'){
            d--;
            dm -= m;
        }

        if (prev == 'M'){
            m--;
        }

        if (next == 'D') d++;
        if (next == 'M'){
            m++;
            dm += d;
        }
        if (next == 'C'){
            ret += dm;
        }
    }

    return ret;
}

int main() {
    cin >> N >> S >> Q;
    while(Q--){
        ll k; cin >> k;
        cout << solve(k) << "\n";
    }
}
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define F first
#define S second
using namespace std;

typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<ld> vld;
typedef pair<ll, ll> pll;

int main()
{
    ll t, i, j, k, ans, n, m, sum = 0, x;

    //cin>>t;
    t = 1;
    while (t--)
    {
        cin >> n >> m;
        string s;
        vll wa(n + 1), ac(n + 1);

        ll c1 = 0, c2 = 0;
        rep(p, 0, m)
        {
            cin >> x >> s;
            if (s == "WA")
                wa[x]++;
            else
            {
                if (ac[x] == 0)
                {
                    c1++;
                    c2 += wa[x];
                    ac[x] = 1;
                }
            }
        }

        cout << c1 << " " << c2;
    }

    return 0;
}
