#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <class T, class C>
void chmax(T& a, C b) {
  a > b ?: a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
  a < b ?: a = b;
}
int main() {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  long long hoge[200010];
  for (int i = 0; i < N; ++i) {
    hoge[i] = 1;
  }
  char t;
  char d;
  for (int i = 0; i < Q; ++i) {
    cin >> t >> d;
    for (int j = 0; j < N; ++j) {
      if (s[j] == t) {
        if (d == 'L') {
          if (j == 0) {
            hoge[j] = 0;
            continue;
          }
          hoge[j - 1] += hoge[j];
          hoge[j] = 0;
        } else if (d == 'R') {
          if (j == N - 1) {
            hoge[j] = 0;
            continue;
          }
          hoge[j + 1] += hoge[j];
          hoge[j] = 0;
        }
      }
    }
  }
  int r = 0;
  for (int i = 0; i < N; ++i) {
    r += hoge[i];
  }
  cout << r << endl;
  return 0;
}
