#include <bits/stdc++.h>
using namespace std;
class Golem {
 public:
  vector<pair<char, int> > masu;
  Golem(int N, string s) {
    pair<char, int> tmp;
    for (int i = 0; i < N; i++) {
      tmp = make_pair(s[i], 1);
      masu.push_back(tmp);
    }
  }
  int move(char t, char d) {
    int extinctionCount = 0;
    if (d == 'L') {
      for (int i = 0; i < masu.size(); i++) {
        if (masu[i].first == t) {
          if (i == 0) {
            extinctionCount += masu[i].second;
            masu[i].second = 0;
          } else {
            masu[i - 1].second += masu[i].second;
            masu[i].second = 0;
          }
        }
      }
    } else {
      for (int i = masu.size() - 1; i >= 0; i--) {
        if (masu[i].first == t) {
          if (i == masu.size() - 1) {
            extinctionCount += masu[i].second;
            masu[i].second = 0;
          } else {
            masu[i + 1].second += masu[i].second;
            masu[i].second = 0;
          }
        }
      }
    }
    return extinctionCount;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  Golem gol(N, s);
  char A, B;
  int extinctionGolem = 0;
  for (int i = 0; i < Q; i++) {
    cin >> A >> B;
    extinctionGolem += gol.move(A, B);
  }
  cout << N - extinctionGolem << endl;
  return 0;
}
