#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<std::pair<char, int> > spaces;
  vector<std::pair<char, char> > moves;
  for (int i = 0; i < q; ++i) {
    std::pair<char, char> pair;
    cin >> pair.first >> pair.second;
    moves.push_back(pair);
  }
  for (int i = 0; i < s.length(); ++i) {
    spaces.push_back(std::pair<char, int>(s[i], 1));
  }
  for (int i = 0; i < q; ++i) {
    auto move = moves[i];
    for (int j = 0; j < n; ++j) {
      if (move.first == spaces[j].first) {
        spaces[j].second--;
        if (move.second == 'L') {
          if (j > 0) {
            spaces[j - 1].second++;
          }
        } else {
          if (j < n - 1) {
            spaces[j + 1].second++;
          }
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += spaces[i].second;
  }
  cout << sum;
}
