#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<string, string>> v;
  for (long long int i = (0); i < (Q); ++i) {
    string t, d;
    cin >> t >> d;
    v.push_back(make_pair(t, d));
  }
  long long int maxl = 0;
  long long int nowl = 0;
  for (long long int i = (0); i < (Q); ++i) {
    if (nowl >= N) {
      break;
    }
    long long int q_idx = Q - i - 1;
    if (v[q_idx].first[0] == s[nowl]) {
      if (v[q_idx].second[0] == 'L') {
        nowl++;
        if (nowl > maxl) {
          maxl = nowl;
        }
      }
    } else if (nowl != 0) {
      if (v[q_idx].first[0] == s[nowl - 1]) {
        if (v[q_idx].second[0] == 'R') {
          nowl = 0;
        }
      }
    }
  }
  long long int maxr = 0;
  long long int nowr = 0;
  for (long long int i = (0); i < (Q); ++i) {
    if (nowr >= N) {
      break;
    }
    long long int q_idx = Q - i - 1;
    if (v[q_idx].first[0] == s[N - nowr - 1]) {
      if (v[q_idx].second[0] == 'R') {
        nowr++;
        if (nowr > maxr) {
          maxr = nowr;
        }
      }
    } else if (nowr != 0) {
      if (v[q_idx].first[0] == s[N - nowr]) {
        if (v[q_idx].second[0] == 'L') {
          nowr = 0;
        }
      }
    }
  }
  long long int score = min(N, maxr + maxl);
  cout << N - score << endl;
}
