#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<pair<char, int> > s_cnt(n + 10, make_pair('0', 1));
  for (int i = 1; i <= n; i++) {
    cin >> s_cnt[i].first;
  }
  vector<pair<char, char> > t_d(n + 10, make_pair('0', '0'));
  for (int i = 1; i <= q; i++) {
    cin >> t_d[i].first >> t_d[i].second;
  }
  vector<int> tmp(n + 10, 0);
  for (int i = 1; i <= q; i++) {
    for (int j = 1; j <= n; j++) {
      if (s_cnt[j].first == t_d[i].first) {
        if (t_d[i].second == 'R' && s_cnt[j].second > 0) {
          tmp[j + 1] += s_cnt[j].second;
          s_cnt[j].second = 0;
        } else if (t_d[i].second == 'L' && s_cnt[j].second > 0) {
          tmp[j - 1] += s_cnt[j].second;
          s_cnt[j].second = 0;
        }
      }
    }
    for (int j = 1; j <= n; j++) {
      if (tmp[j] > 0) {
        s_cnt[j].second += tmp[j];
      }
      tmp[j] = 0;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += s_cnt[i].second;
  }
  cout << ans << endl;
}
