#include <bits/stdc++.h>
using namespace std;
int main() {
  map<char, vector<int>> m;
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int count[n];
  for (int i = 0; i < s.size(); i++) {
    m[s[i]].push_back(i);
    count[i] = 1;
  }
  int cnt = n;
  char t, d;
  while (q--) {
    cin >> t >> d;
    int dir;
    if (d == 'L')
      dir = -1;
    else
      dir = 1;
    for (int i = 0; i < m[t].size(); i++) {
      int temp = count[m[t][i]];
      count[m[t][i]] = 0;
      if (dir == -1 && m[t][i] != 0)
        count[m[t][i] + dir] += temp;
      else if (dir == 1 && m[t][i] != n - 1)
        count[m[t][i] + dir] += temp;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += count[i];
  }
  cout << sum;
  return 0;
}
