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

using namespace std;

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

    auto f = [&](int p) -> int
    {
        if (p>=N)
            return 1;
        for (int i=0; i<Q; i++)
        {
            if (s[p]==t[i])
                if (d[i]=='L')
                    p--;
                else
                    p++;
            if (p<0)
                return -1;
            if (p>=N)
                return 1;
        }
        return 0;
    };

    int B = 1;
    while (B<N)
        B *= 2;

    int l = -1;
    for (int b=B; b>0; b/=2)
        if (f(l+b)==-1)
            l += b;
    int r = -1;
    for (int b=B; b>0; b/=2)
        if (f(r+b)!=1)
            r += b;
    cout<<r-l<<endl;
}
