#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, char>> td(q);
  for (long long i = 0, i_len = (q); i < i_len; i++)
    cin >> td[i].first >> td[i].second;
  map<char, vector<long long>> m;
  for (long long i = 0, i_len = (n); i < i_len; i++) m[s[i]].push_back(i);
  long long delcnt = 0;
  for (long long i = 0, i_len = (q); i < i_len; i++) {
    char t = td[i].first;
    long long d = ((td[i].second == 'L') ? -1 : 1);
    vector<long long> add;
    for (auto idx : m[t]) {
      if (((idx == 0) && (d == -1)) || ((idx == (n - 1)) && (d == 1))) {
        delcnt++;
        continue;
      }
      char next = s[idx + d];
      if (next == t) {
        add.push_back(idx + d);
      } else {
        m[next].push_back(idx + d);
      }
    }
    m[t].clear();
    for (long long i = 0, i_len = (((long long)(add).size())); i < i_len; i++)
      m[t].push_back(add[i]);
  }
  cout << (n - delcnt) << endl;
  return 0;
}
