#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<vector<int> > char_pos(26);
  for (int i = 0; i < s.length(); i++) {
    char_pos[s[i] - 'A'].push_back(i);
  }
  int ctr[n];
  for (int i = 0; i < n; i++) ctr[i] = 1;
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < char_pos[t - 'A'].size(); j++) {
      int curr_ind = char_pos[t - 'A'][j];
      if (ctr[curr_ind] == 0)
        continue;
      else {
        if (curr_ind == 0 && d == 'L')
          ctr[curr_ind] = 0;
        else if (curr_ind == n - 1 && d == 'R')
          ctr[curr_ind] = 0;
        else {
          if (d == 'L') {
            int new_ind = curr_ind - 1;
            ctr[new_ind] += ctr[curr_ind];
            ctr[curr_ind] = 0;
          } else {
            int new_ind = curr_ind + 1;
            ctr[new_ind] += ctr[curr_ind];
            ctr[curr_ind] = 0;
          }
        }
      }
    }
  }
  int total = 0;
  for (int i = 0; i < n; i++) {
    total += ctr[i];
  }
  cout << total;
  return 0;
}
