#include <bits/stdc++.h>
using namespace std;
class Place {
 public:
  int golem_number;
  string sign;
};
class Magic {
 public:
  string location;
  string word;
};
int main() {
  int N, Q;
  string S;
  int golem_number;
  Place c_place;
  Magic magic;
  string s1, s2;
  vector<Place> vplaces;
  vector<Magic> vmagics;
  string L = "L";
  string R = "R";
  int result = 0;
  cin >> N >> Q >> S;
  for (int i = 0; i < Q; i++) {
    cin >> s1 >> s2;
    magic.location = s1;
    magic.word = s2;
    vmagics.push_back(magic);
  }
  for (int i = 0; i < N; i++) {
    c_place.golem_number = 1;
    c_place.sign = S[i];
    vplaces.push_back(c_place);
  }
  for (int m_number = 0; m_number < Q; m_number++) {
    for (int p_number = 0; p_number < N; p_number++) {
      if (vmagics.at(m_number).location == vplaces.at(p_number).sign) {
        if (vmagics.at(m_number).word == L) {
          if (vplaces.at(p_number).golem_number > 0) {
            golem_number = vplaces.at(p_number).golem_number;
            vplaces.at(p_number).golem_number = 0;
            if (p_number > 0) {
              vplaces.at(p_number - 1).golem_number += golem_number;
            }
          }
        }
        if (vmagics.at(m_number).word == R) {
          if (vplaces.at(p_number).golem_number > 0) {
            golem_number = vplaces.at(p_number).golem_number;
            vplaces.at(p_number).golem_number = 0;
            if (p_number < N - 1) {
              vplaces.at(p_number + 1).golem_number += golem_number;
            }
          }
        }
      }
    }
  }
  for (int p_number = 0; p_number < N; p_number++) {
    result += vplaces.at(p_number).golem_number;
  }
  cout << result << endl;
  return 0;
}
