#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n, q; cin >> n >> q;
  string s; cin >> s;
  vector<char> t(q), d(q);
  REP(i, q) cin >> t[i] >> d[i];
  
  map<pair<char, char>, int> memo;
  REP(i, n) memo[make_pair(t[i], d[i])] = i;

  int l = -1, r = n, cnt = 0, lrm = 1, rrm = 1;
  for(int i=q-1; i>=0; i--){
    if(d[i] == 'L' && s[l+1] == t[i]){
      auto p = make_pair(t[i], 'R');
      if(memo[p] != 0 && memo[p] < i){
        lrm++;
      } else {
        cnt += lrm;
        lrm = 1;
      }
      l++;
    } 
      
    if(d[i] == 'R' && s[r-1] == t[i]){
      auto p = make_pair(t[i], 'L');
      if(memo[p] != 0 && memo[p] < i){
        rrm++;
      } else {
        cnt += rrm;
        rrm = 1;
      }
      r--;
    }
  }

  cout << n - cnt << endl;

  return 0;
}
