#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 28);
int n, q;
string s;
char t[200000], d[200000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  s = s.c_str();
  int g = n;
  int count[n];
  for (int i = 0; i < n; i++) {
    count[i] = 1;
  }
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (t[i] == s[j] && count[j] > 0) {
        if (d[i] == 'L') {
          int temp = j - 1;
          if (j - 1 < 0) {
            g = g - count[j];
            count[j] = 0;
          } else {
            count[temp] += count[j];
            count[j] = 0;
          }
        } else {
          int temp = j + 1;
          if (j + 1 > n - 1) {
            g = g - count[j];
            count[j] = 0;
          } else {
            count[temp] += count[j];
            count[j] = 0;
          }
        }
      }
    }
  }
  cout << g << "\n";
}
