#include<bits/stdc++.h>
using namespace std;

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

string s;

bool seeAns(ll x, char t[], char d[], ll q, ll n)
{
    char charnow = s[x];

    ll pos = x;

    bool ans = 0;

    rep(i,q)
    {
        // if(x==1)
        // {
        //     cout << charnow << " " << pos << " " << d[i] << " " << t[i] << endl;
        // }
        if(t[i]==charnow)
        {
            if(d[i]=='R')
            {
                pos++;
                if(pos==n)
                    break;
                else
                {
                    charnow = s[pos];
                }
            }
            else
            {
                pos--;
                if(pos==-1)
                {
                    ans = 1;
                    break;
                }
                else
                    charnow = s[pos];
            }
        }
    }

    // if(x==1)
    //     cout << ans << endl;
    return ans;
}

bool seeAns2(ll x, char t[], char d[], ll q, ll n)
{
    char charnow = s[x];

    ll pos = x;

    bool ans = 0;

    rep(i,q)
    {
        // if(x==6)
        //     cout << charnow << " " << pos << " " << t[i] << endl;
        if(t[i]==charnow)
        {
            if(d[i]=='R')
            {
                pos++;
                if(pos==n)
                {
                    ans = 1;
                    break;
                }
                else
                {
                    charnow = s[pos];
                }
            }
            else
            {
                pos--;
                if(pos==-1)
                {
                    ans = 0;
                    break;
                }
                else
                    charnow = s[pos];
            }
        }
    }

    return ans;
}

ll binSearch1(ll st, ll en, char t[], char d[], ll q, ll n)
{
    if(st==en)
    {
        bool ans = 0;
        ans = seeAns(st,t,d,q,n);

        if(ans)
        {
            // cout << "F";
            return st;
        }
        // cout << st << endl;
        return st-1;
    }

    ll mid = (st+en)/2;

    bool ans = seeAns(mid,t,d,q,n);

    if(!ans)
        return binSearch1(st,mid,t,d,q,n);
    return binSearch1(mid+1,en,t,d,q,n);
}

ll binSearch2(ll st, ll en, char t[], char d[], ll q, ll n)
{
    if(st==en)
    {
        bool ans = 0;
        if(st!=0)
            ans = seeAns2(st-1,t,d,q,n);

        if(ans)
            return st-1;

        if(seeAns2(st,t,d,q,n))
            return st;
        return st+1;
    }

    ll mid = (st+en)/2;

    bool ans = seeAns2(mid,t,d,q,n);

    if(ans)
        return binSearch2(st,mid,t,d,q,n);
    return binSearch2(mid+1,en,t,d,q,n);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    ll n,q;
    cin >> n >> q;

    cin >> s;

    char t[q];
    char d[q];

    rep(i,q)
    {
        cin >> t[i] >> d[i];
    }

    ll fromLeft = binSearch1(0,n-1,t,d,q,n);
    ll fromRight = binSearch2(0,n-1,t,d,q,n);

    ll ans = fromLeft+1 + n-fromRight;

    // cout << fromLeft << " " << fromRight << endl;
    cout << n-ans << endl;
}


Measured memory_bytes: 976