#include <bits/stdc++.h>
using namespace std;
void move(vector<long>& gn, string s, char t, char d) {
  vector<long> temp = gn;
  for (long i = 0; i < gn.size(); ++i) {
    if (i == 0 and s[0] == t and d == 'L') {
      temp[0] = 0;
    } else if (i == gn.size() - 1 and s[i] == t and d == 'R') {
      temp[i] = 0;
    } else if (s[i] == t) {
      if (d == 'L') {
        temp[i - 1] += gn[i];
        temp[i] -= gn[i];
      } else {
        temp[i + 1] += gn[i];
        temp[i] -= gn[i];
      }
    }
  }
  gn = temp;
}
class go {
 public:
  go(long init_idx, char init_now);
  long idx;
  char now;
  bool alive;
  void mv(char t, char d, string s);
};
go::go(long init_idx, char init_now) {
  idx = init_idx;
  now = init_now;
  alive = true;
}
void go::mv(char t, char d, string s) {
  if (now == t) {
    if (d == 'L') {
      --idx;
    } else if (d == 'R') {
      ++idx;
    }
  }
  if (idx < 0 or idx >= s.size()) {
    alive = false;
  } else {
    now = s[idx];
  }
}
int main() {
  long n, q;
  cin >> n >> q;
  string s;
  vector<char> t(q), d(q);
  cin >> s;
  for (long i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  long total = n;
  for (long i = 0; i < n; ++i) {
    go g(i, s[i]);
    for (long qi = 0; qi < q; ++qi) {
      g.mv(t[qi], d[qi], s);
      if (!g.alive) {
        --total;
        break;
      }
    }
  }
  cout << total << endl;
  return 0;
}
