#include <iostream>

int main() {
    int N, Q;
    std::string S;
    
    std::cin >> N >> Q;
    std::cin >> S;
    
    using P = std::pair<char, char>;
    P temp, td[NMAX];
    
    for (int i=0; i<Q; ++i) {
        std::cin >> temp.first >> temp.second;
        td[i] = temp;
    }
    
    int lcur = -1;
    int rcur = N;
    for (int i=Q-1; i>=0; --i) {
        //std::cout << td[i].first << " " << td[i].second << std::endl;
        
        if (S[lcur+1]==td[i].first && td[i].second=='L') {
            lcur++;
        } else if (S[lcur-1]==td[i].first && td[i].second=='R' && lcur!=-1) {
            lcur--;
        } else if (S[rcur-1]==td[i].first && td[i].second=='R') {
            rcur--;
        } else if (S[rcur+1]==td[i].first && td[i].second=='L' && rcur!=N) {
            rcur++;
        }
        
        //std::cout << lcur << " " << rcur << std::endl;
    }
    int ans = N;
    if (lcur >= 0) ans -= lcur+1;
    if (rcur <= N-1) ans -= (N-1) - rcur + 1;
    std::cout << ans << std::endl;
}