#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

signed main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<pair<char, char>> move(Q);
    for (int i = 0; i < Q; i++) {
        char t, d;
        cin >> t >> d;
        move[i] = {t, d};
    }
    reverse(move.begin(), move.end());
    vector<bool> ans(N, true);
    int left = -1, right = N;
    for (auto now : move) {
        if (now.second == 'L') {
            if (S[left + 1] == now.first) {
                left++;
                ans[left] = false;
            }
            if (right < N - 1 && S[right + 1] == now.second) right++;
        } else {
            if (S[right - 1] == now.first) {
                right--;
                ans[right] = false;
            }
            if (left >= 1 && S[left - 1] == now.first) left--;
        }
        if (left == right) break;
    }
    int count = 0;
    for (int i = 0; i < N; i++) count += ans[i];
    cout << count << endl;
}
