#include <bits/stdc++.h>
using namespace std;
int saikif(int xx, int Q, int N, vector<vector<int>> &vvi, vector<int> &si) {
  int x = xx;
  int houkou = 1;
  if (x < 0) {
    houkou = -1;
  }
  int lefts = 0;
  int righs = 0;
  int mids = 0;
  int sQ = Q - 1;
  int gntotal = 0;
  vector<int> saikx(200000, 0);
  vector<int> saikq(200000, 0);
  int saikpos = 0;
  saikpos = 0;
  for (int j = 0; j < Q * Q; j++) {
    if (x > 0) {
      lefts = si[x - 1];
    } else {
      lefts = 0;
    }
    if (x < N - 1) {
      righs = si[x + 1];
    } else {
      righs = 0;
    }
    if ((x != -1) & (x != N)) {
      mids = si[x];
    } else {
      mids = 0;
    }
    for (int i = sQ; i >= -3; i--) {
      if (i < 0) {
        saikpos = -1;
        break;
      }
      if (houkou == -1) {
        if (righs != 0) {
          if (vvi[righs - 65][i] == 1) {
            saikpos++;
            saikx[saikpos] = x;
            saikq[saikpos] = i - 1;
            sQ = saikq[saikpos];
            x++;
            break;
          }
        }
      }
      if (houkou == 1) {
        if (lefts != 0) {
          if (vvi[lefts - 65][i] == 2) {
            saikpos++;
            saikx[saikpos] = x;
            saikq[saikpos] = i - 1;
            sQ = saikq[saikpos];
            x--;
            break;
          }
        }
      }
    }
    if (saikpos < 0) break;
  }
  return abs(xx - x);
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  string inT, inD;
  vector<int> si(N, 0);
  for (int i = 0; i < N; i++) {
    si[i] = int(s[i]);
  }
  vector<int> t(Q, 0);
  vector<int> d(Q, 0);
  vector<vector<int>> vvi = vector<vector<int>>(27, vector<int>(Q, 0));
  for (int i = 0; i < Q; i++) {
    cin >> inT >> inD;
    t[i] = int(inT[0]);
    d[i] = int(inD[0]);
    vvi[t[i] - 65][i] = (d[i] - 76) / 6 + 1;
  }
  int ans1 = saikif(N, Q, N, vvi, si);
  int ans2 = saikif(-1, Q, N, vvi, si);
  int ans3 = (N - ans1 - ans2);
  if (ans3 < 0) {
    ans3 = 0;
  }
  cout << ans3 << endl;
  return 0;
}
