#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = {0, -1, 1, 0};
const int dy[4] = {-1, 0, 0, 1};
const int INF = 1e9 + 7;
int gcd(int x, int y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return gcd(y, x % y);
}
template <class T1, class T2>
void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <class T1, class T2>
void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) {
    val += mod;
  }
  a = val;
}
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  int ans = N;
  vector<char> kind[200100];
  for (int i = 0; i < N; ++i) {
    kind[i].push_back(s[i]);
  }
  for (int i = 0; i < Q; ++i) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < N; ++j) {
      for (auto k : kind[j]) {
        if (k == t) {
          if (j == 0 && d == 'L') {
            ans -= kind[j].size();
            kind[j].clear();
            break;
          } else if (j == N - 1 && d == 'R') {
            ans -= kind[j].size();
            kind[j].clear();
            break;
          } else {
            if (d == 'L') {
              while (!kind[j].empty()) {
                kind[j - 1].push_back(kind[j][kind[j].size() - 1]);
                kind[j].pop_back();
              }
              break;
            } else {
              while (!kind[j].empty()) {
                kind[j + 1].push_back(kind[j][kind[j].size() - 1]);
                kind[j].pop_back();
              }
              break;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
