#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
template <typename T>
void putv(vector<T>& V) {
  for (auto x : V) cout << x << " ";
  cout << endl;
}
template <class T>
vector<T> getv(long long n) {
  vector<T> Vector_temp;
  for (int(i) = 0; (i) < (n); (i)++) {
    T input;
    cin >> input;
    Vector_temp.emplace_back(input);
  }
  return Vector_temp;
}
long long gcd(long long c, long long b) {
  while (1) {
    if (c % b != 0) {
      long long tmp = b;
      b = c % b;
      c = tmp;
    } else {
      return b;
    }
  }
}
int main() {
  long long n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> t(q);
  vector<char> d(q);
  char sf = s[0];
  char se = s[s.size()];
  for (int(i) = 0; (i) < (q); (i)++) {
    cin >> t[i] >> d[i];
  }
  long long cnt = 0;
  long long ans = 0;
  bool f = false;
  for (int i = q - 1; i >= 0; i--) {
    if (cnt >= n) break;
    if (d[i] == 'L') {
      if (s[cnt] == t[i]) {
        cnt++;
        f = false;
      }
    } else if (cnt > 0) {
      if (s[cnt - 1] == t[i]) {
        f = true;
        ans = max(ans, (cnt - 1));
        cnt = 0;
      }
    }
  }
  ans = max(ans, cnt);
  long long cnt2 = 0;
  long long ans2 = 0;
  bool F = false;
  for (int i = q - 1; i >= 0; i--) {
    if (cnt2 >= n) break;
    if (d[i] == 'R') {
      if (s[s.size() - 1 - cnt2] == t[i]) {
        cnt2++;
        F = false;
      }
    } else if (cnt2 > 0) {
      if (s[s.size() - cnt2] == t[i]) {
        F = true;
        ans2 = max(ans2, (cnt2 - 1));
        cnt2 = 0;
      }
    }
  }
  ans2 = max(ans2, cnt2);
  long long Ans = ((n - (ans + ans2)) >= 0 ? (n - (ans + ans2)) : 0);
  cout << (Ans) << endl;
  ;
  return 0;
}
