#include <bits/stdc++.h>
using namespace std;
const int M = 200000;
string L = "L", R = "R";
int N;
string s;
vector<string> t, d;
vector<int> visited;
void dfs(int pos, int turn) {
  if (turn >= 0 && pos < N - 1) {
    for (int i = turn - 1; i >= 0; --i) {
      if (pos + 1 < N && t[i][0] == s[pos + 1] && d[i] == L) {
        visited[pos + 1] = true;
        dfs(pos + 1, i);
      }
    }
  }
  if (turn >= 0 && pos > 1) {
    for (int i = turn - 1; i >= 0; --i) {
      if (pos - 1 >= 0 && t[i][0] == s[pos - 1] && d[i] == R) {
        visited[pos - 1] = true;
        dfs(pos - 1, i);
      }
    }
  }
}
int main() {
  int Q;
  cin >> N >> Q;
  cin >> s;
  t.resize(Q);
  d.resize(Q);
  visited.resize(N);
  for (int i = 0; i < Q; ++i) {
    cin >> t[i] >> d[i];
  }
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    visited[i] = false;
  }
  dfs(-1, Q);
  for (int i = 0; i < N; ++i) {
    if (visited[i]) {
      cnt++;
    }
  }
  for (int i = 0; i < N; ++i) {
    visited[i] = false;
  }
  dfs(N, Q);
  for (int i = 0; i < N; ++i) {
    if (visited[i]) {
      cnt++;
    }
  }
  cout << N - cnt << endl;
  return 0;
}
