#include <bits/stdc++.h>
using namespace std;
int num_tile, num_spell;
string S;
std::vector<char> tile(0);
std::vector<char> spell(0);
int main(void) {
  cin >> num_tile >> num_spell;
  cin >> S;
  char temp_char, spell_temp;
  for (int i = 0; i < num_spell; ++i) {
    cin >> temp_char >> spell_temp;
    tile.push_back(temp_char);
    spell.push_back(spell_temp);
  }
  std::vector<int> gorem(num_tile, 1);
  for (int j = 0; j < num_spell; ++j) {
    if (spell[j] == 'R') {
      for (int pos = num_tile - 1; pos >= 0; --pos) {
        if (tile[j] == S[pos]) {
          if (pos == num_tile - 1) {
            gorem[pos] = 0;
          } else {
            gorem[pos + 1] += gorem[pos];
            gorem[pos] = 0;
          }
        }
      }
    } else {
      for (int pos = 0; pos < num_tile; ++pos) {
        if (tile[j] == S[pos]) {
          if (pos == 0) {
            gorem[0] = 0;
          } else {
            gorem[pos - 1] += gorem[pos];
            gorem[pos] = 0;
          }
        }
      }
    }
  }
  int sum_temp = 0;
  for (int i = 0; i < num_tile; ++i) sum_temp += gorem[i];
  cout << sum_temp << endl;
}
