#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<int, int> > cell;
  for (int i = 0; i < N; ++i) {
    cell.push_back(pair<int, int>(i, 1));
  }
  for (int i = 0; i < Q; ++i) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < cell.size(); ++j) {
      int k = (d == 'L') ? j : cell.size() - j - 1;
      int step = (d == 'L') ? -1 : 1;
      auto& cur = cell[k];
      if (s[cur.first] == t) {
        if (0 <= cur.first + step && cur.first + step < N) {
          cur.first += step;
          int nk = k + step;
          if (0 <= nk && nk < cell.size()) {
            if (cell[nk].first == cur.first) {
              cell[nk].second += cur.second;
              cell.erase(cell.begin() + k);
              --j;
            }
          }
        } else {
          cell.erase(cell.begin() + k);
          --j;
        }
      }
    }
  }
  int sum = 0;
  for (auto e : cell) sum += e.second;
  cout << sum << endl;
}
