#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
template <class T>
inline bool amax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool amin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
struct aaa {
  aaa() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} aaaaaaa;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const db EPS = 1e-9;
const int dx[] = {1, 1, 0, -1, -1, -1, 0, 1},
          dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
signed main() {
  int n;
  cin >> n;
  int q;
  cin >> q;
  string s;
  cin >> s;
  vi bo(n, 1);
  int total = n;
  char wh, si;
  for (int i = 0, i_len = (q); i < i_len; ++i) {
    cin >> wh >> si;
    for (int i = 0, i_len = (n); i < i_len; ++i) {
      if (s[i] == wh) {
        if (si == 'L') {
          if (i == 0) {
            total -= bo[0];
          }
          if (i != 0) bo[i - 1] += bo[i];
          bo[i] = 0;
        }
        if (si == 'R') {
          if (i == n - 1) {
            total -= bo[n - 1];
          }
          if (i != n - 1) bo[i + 1] += bo[i];
          bo[i] = 0;
        }
      }
    }
  }
  cout << total;
  return 0;
}
