#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
vector<char> t, d;
int check(int m) {
  set<char> se;
  se.insert(s[m]);
  for (int i = 0; i < Q; i++) {
    if (se.find(t[i]) != se.end()) {
      if (d[i] == 'L') {
        m--;
      } else {
        m++;
      }
      if (m != -1 && m != N) {
        se.insert(s[m]);
      } else {
        break;
      }
    }
  }
  return m;
}
int left() {
  int l = 0, r = N;
  bool judge = false;
  for (int i = 0; i < 100; i++) {
    int m = (r + l) / 2;
    if (check(m) == -1) {
      l = m;
      judge = true;
    } else {
      r = m - 1;
    }
  }
  if (judge) {
    return l;
  } else {
    return -1;
  }
}
int right() {
  int l = 0, r = N;
  bool judge = false;
  for (int i = 0; i < 100; i++) {
    int m = (r + l) / 2;
    if (check(m) == N) {
      r = m;
      judge = true;
    } else {
      l = m;
    }
  }
  if (judge) {
    return r;
  } else {
    return -1;
  }
}
int main() {
  cin >> N >> Q;
  cin >> s;
  t.resize(Q);
  d.resize(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int le = left();
  int ri = right();
  if (le != -1 && ri != -1) {
    cout << ri - le - 1 << endl;
  } else if (ri != -1) {
    cout << ri << endl;
  } else if (le != -1) {
    cout << N - (le + 1) << endl;
  } else {
    cout << N << endl;
  }
}
