#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
vector<pair<char, char> > Q;
int tmp;
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) {
    char a, b;
    cin >> a >> b;
    Q.push_back(pair<char, char>(a, b));
  }
  int ans = 0;
  int ans2 = 0;
  for (int i = Q.size() - 1; i >= 0; i--) {
    if (Q[i].first == s[0] && Q[i].second == 'L') {
      int k = i - 1;
      int j = 1;
      int tmp = 1;
      while (k >= 0 || (Q[k].first == s[j] && Q[k].second == 'R')) {
        if (Q[k].first == s[j] && Q[k].second == 'L') {
          j++;
          tmp++;
        }
        k--;
      }
      ans = max(ans, tmp);
      i = k + 1;
    }
  }
  for (int i = Q.size() - 1; i >= 0; i--) {
    if (Q[i].first == s[s.size() - 1] && Q[i].second == 'R') {
      int k = i - 1;
      int j = s.size() - 2;
      int tmp = 1;
      while (k >= 0 || (Q[k].first == s[j] && Q[k].second == 'L')) {
        if (Q[k].first == s[j] && Q[k].second == 'R') {
          j--;
          tmp++;
        }
        k--;
      }
      ans2 = max(ans2, tmp);
      i = k + 1;
    }
  }
  cout << n - (ans + ans2) << endl;
}
