//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<string> qu;
    while (q--) {
        char s, t;
        cin >> s >> t;
        string tmp(1, s);
        tmp.push_back(t);
        qu.push_back(tmp);
    }
    reverse(qu.begin(), qu.end());

    int l = 0;
    int r = n + 1;

    for (const auto& cu : qu) {
        if (cu[1] == 'R')
            if (r > l && s[r - 2] == cu[0])
                --r;
        if (cu[1] == 'L')
            if (r > l && s[l] == cu[0])
                ++l;
    }
    cout << n - (l + n + 1 - r) << endl;
}
