#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  char t[210000], d[210000];
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int num[210000];
  for (int i = 0; i < n; i++) num[i] = 1;
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (s[j] == t[i]) {
        if (j == 0 && d[i] == 'L')
          num[0] = 0;
        else if (j == n - 1 && d[i] == 'R')
          num[n - 1] = 0;
        else {
          int g = num[j];
          num[j] = 0;
          if (d[i] == 'L')
            num[j - 1] += g;
          else
            num[j + 1] += g;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += num[i];
  }
  cout << sum << endl;
}
