#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef struct _Magic {
  char place;
  char move;
} Magic;
typedef struct _Field {
  char type;
  int golems;
} Field;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<Field> g(N);
  for (int i = 0; i < (int)s.size(); ++i) {
    Field f;
    f.type = s[i];
    f.golems = 1;
    g[i] = f;
  }
  vector<Magic> v(Q);
  for (int i = 0; i < Q; ++i) {
    Magic m;
    cin >> m.place >> m.move;
    v[i] = m;
  }
  int ans = 0;
  for (int i = 0; i < Q; ++i) {
    char p = v[i].place;
    char m = v[i].move;
    for (int j = 0; j < N; ++j) {
      if (g[j].type == p) {
        if (m == 'L') {
          if (j == 0) {
            ans += g[j].golems;
            g[j].golems = 0;
          } else {
            g[j - 1].golems += g[j].golems;
            g[j].golems = 0;
          }
        } else {
          if (j == N - 1) {
            ans += g[j].golems;
            g[j].golems = 0;
          } else {
            g[j + 1].golems += g[j].golems;
            g[j].golems = 0;
          }
        }
      }
    }
  }
  cout << N - ans << endl;
}
