#include <bits/stdc++.h>
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using namespace std;
class Solve {
 public:
  void input() {}
  void solve() {
    input();
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<pair<char, char>> vs(Q);
    for (int i = int(0); i < int(Q); i++) cin >> vs[i].first >> vs[i].second;
    reverse(begin(vs), end(vs));
    int lsafe = 0;
    int rsafe = N - 1;
    for (int i = 0; i < Q; ++i) {
      if (vs[i].second == 'L') {
        if (lsafe < N && vs[i].first == S[lsafe]) {
          lsafe++;
        }
      } else {
        if (rsafe >= 0 && vs[i].first == S[rsafe]) {
          rsafe--;
        }
      }
    }
    if (lsafe <= rsafe) {
      int ans = rsafe - lsafe + 1;
      cout << ans << endl;
    } else {
      cout << 0 << endl;
    }
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solve().solve();
  return 0;
}
