#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


int main()
{
    int N, Q;
    string s;
    cin >> N >> Q >> s;
    vector<char> t(Q);
    vector<char> d(Q);
    REP(i, Q) cin >> t[i] >> d[i];

    int L = -1, R = N;
    IREP(i, Q)
    {
        if (d[i] == 'L')
        {
            L += (L + 1 < N and s[L + 1] == t[i]);
            R += (R < N and s[R] == t[i]);
        }
        else
        {
            L -= (L >= 0 and s[L] == t[i]);
            R -= (R > 0 and s[R - 1] == t[i]);
        }
        if (L + 1 >= R) break;
    }
    cout << max(R - L - 1, 0) << endl;
}
