#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret;
    for (VType i = start; i < end; i++) ret.push_back(i);
    return move(ret);
}
multimap<char, deque<int>> pos;

void erase(auto& ite) {
    auto temp = ite;
    temp++;
    pos.erase(temp);
    ite = temp;
}

int main() {
    int N(in()), Q(in());
    uint64_t gs[N];

    for (int i : LR(0, N)) {
        char c;
        cin >> c;
        auto ite = pos.find(c);
        if (ite == pos.end()) {
            deque<int> temp;
            temp.push_back(i);
            pos.insert(make_pair(c, temp));            
        } else {
            ite->second.push_back(i);
        }
        gs[i] = 1;            
    }

    for (int i : LR(0, Q)) {
        char name;
        cin >> name;
        char muki;
        cin >> muki;
        auto ite = pos.find(name);
        if (pos.end () == ite) continue;
        auto ite2 = ite->second.begin();
        while (ite2 != ite->second.end()) {

            if (muki == 'L') {
                if (*ite2 == 0) {
                    gs[0] = 0;
                } else {
                    gs[*ite2 - 1] += gs[*ite2];
                    gs[*ite2] = 0;
                }
            } else  {
                if (*ite2 == (N - 1)) {
                    gs[N - 1] = 0;
                } else {
                    gs[*ite2 + 1] += gs[*ite2];
                    gs[*ite2] = 0;
                }
            }
            ite2++;
        }
    }

    uint64_t sum = 0;
    for (uint64_t temp : gs) {
        sum += temp;
    }
    cout << sum << endl;
    return 0;
}


