#include <bits/stdc++.h>
using namespace std;
int n, q;
map<char, vector<int>> m;
string s;
int dp[300000];
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < n; i++) {
    m[s[i]].push_back(i + 1);
    dp[i + 1] = 1;
  }
  int ans = n;
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    int dx = 0;
    if (d == 'L') {
      dx = -1;
    } else {
      dx = 1;
    }
    for (int i = 0; i < m[t].size(); i++) {
      if (m[t][i] + dx <= 0 || m[t][i] + dx > n) {
        ans -= dp[m[t][i]];
        dp[m[t][i]] = 0;
        continue;
      }
      dp[m[t][i] + dx] += dp[m[t][i]];
      dp[m[t][i]] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
