#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;
constexpr long long INF = 1LL << 60;
const double PI = acos(-1);
struct Tll {
  LL first, second, third;
};
struct Fll {
  LL first, second, third, fourth;
};
void YN(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void yn(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
struct Edge {
  LL to, cost;
};
struct edge {
  LL from, to, cost;
};
vector<vector<Edge>> g;
vector<edge> ed;
vector<pair<LL, LL>> pv;
set<LL> st;
map<pair<LL, LL>, LL> ma;
int di[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
string str, ss;
bool f;
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt;
char a[210000], b[210000];
LL L[30], R[30];
int main() {
  cin >> n >> q;
  cin >> str;
  for (LL i = 0; i < 30; i++) L[i] = INF, R[i] = INF;
  for (LL i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    if (b[i] == 'L')
      L[a[i] - ('A')] = min(i, L[a[i] - ('A')]);
    else
      R[a[i] - ('A')] = min(i, R[a[i] - ('A')]);
  }
  LL lx = 1, l = 1, r = n, rx = n;
  for (LL i = q - 1; i >= 0; i--) {
    if (str[l - 1] == a[i] && b[i] == 'L') {
      if (R[str[l - 1] - 'A'] < i) {
      } else
        lx = l + 1;
      l++;
    }
    if (str[r - 1] == a[i] && b[i] == 'R') {
      if (L[str[r - 1] - 'A'] < i) {
      } else
        rx = r - 1;
      r--;
    }
    if (l - 1 == n) break;
    if (r == 0) break;
  }
  ans = lx - 1 + n - rx;
  cout << max(n - ans, 0LL) << endl;
  return 0;
}
