#include <bits/stdc++.h>
using namespace std;
std::mt19937 mt((long long)time(0));
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
using Weight = long long;
using Flow = long long;
struct Edge {
  long long src, dst;
  Weight weight;
  Flow cap;
  Edge() : src(0), dst(0), weight(0) {}
  Edge(long long s, long long d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, long long a, long long b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
  g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, long long a, long long b, Weight w = 1) {
  g[a].emplace_back(a, b, w);
}
vector<pair<char, char>> inst;
long long N, Q;
string s;
long long go[2000000];
void doQuery(pair<char, char> q) {
  for (long long i = 0; i < N; i++) {
    if (go[i] == -1 || go[i] == N) continue;
    if (s[go[i]] == q.first) {
      if (q.second == 'L') {
        go[i]--;
      } else {
        go[i]++;
      }
    }
  }
}
signed main() {
  cin >> N >> Q >> s;
  for (long long i = 0; i < N; i++) {
    go[i] = i;
  }
  for (long long i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    inst.push_back(make_pair(t, d));
  }
  for (auto p : inst) {
    doQuery(p);
  }
  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    if (go[i] >= 0 && go[i] < N) ans++;
  }
  cout << ans << "\n";
  return 0;
}
