#include <bits/stdc++.h>
using namespace std;
long long n, m;
string s;
pair<char, char> d[500000];
signed main() {
  cin >> n >> m;
  cin >> s;
  for (long long i = 0; i < m; i++) cin >> d[i].first >> d[i].second;
  reverse(d, d + m);
  long long p1 = -1, p2 = n, p1max = -1, p2min = n;
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    if (d[i].second == 'R') {
      if (p2 > 0 && s[p2 - 1] == d[i].first) p2--;
      if (p1 > 0 && s[p1 - 1] == d[i].first) p1--;
    } else {
      if (p1 < n - 1 && s[p1 + 1] == d[i].first) p1++;
      if (p2 < n - 1 && s[p2 + 1] == d[i].first) p2++;
    }
    p1max = max(p1max, p1);
    p2min = min(p2min, p2);
  }
  ans = p1max + 1 + n - p2min;
  cout << n - min(n, ans);
}
