#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

template<typename T>
void chmin(T &a, T b) {
    a = min(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    int curl = 0, curr = n;
    vector<char> T(q), D(q);
    REP (i, 0, q) {
        cin >> T[i] >> D[i];
    }
    for (int i = q - 1; i >= 0; i--) {
        char t = T[i], d = D[i];
        if (d == 'L') {
            if (curl < n && S[curl] == t) {
                curl = min(n, curl + 1);
            }
        } else {
            if (curr > 0 && S[curr - 1] == t) {
                curr = max(0, curr - 1);
            }
        }
        dump(curl);
        dump(curr);
    }
    cout << max(0, curr - curl) << endl;
    return 0;
}
