#include <bits/stdc++.h>
using namespace std;
void move_left(int* _lrm, int* _moved_lrm, bool* _success_lrm, int lrm_idx,
               int _t, string _s, string mode) {
  if (!_success_lrm[lrm_idx]) {
    if (_t == _s[_moved_lrm[lrm_idx]]) {
      _moved_lrm[lrm_idx]--;
      if (_moved_lrm[lrm_idx] < 0) {
        if (mode == "LeftSideOut") _success_lrm[lrm_idx] = true;
      }
    }
  }
}
void move_right(int* _lrm, int* _moved_lrm, bool* _success_lrm, int lrm_idx,
                int _t, string _s, string mode, int _N) {
  if (!_success_lrm[lrm_idx]) {
    if (_t == _s[_moved_lrm[lrm_idx]]) {
      _moved_lrm[lrm_idx]++;
      if (_moved_lrm[lrm_idx] > _N - 1) {
        if (mode == "RightSideOut") _success_lrm[lrm_idx] = true;
      }
    }
  }
}
int main() {
  int N, Q;
  string s;
  int lrm[3];
  int moved_lrm[3];
  bool success_lrm[3];
  int max_idx, min_idx;
  cin >> N >> Q;
  cin >> s;
  max_idx = -1, min_idx = N;
  char t_i[Q], d_i[Q];
  for (int q = 0; q < Q; ++q) {
    cin >> t_i[q] >> d_i[q];
  }
  lrm[0] = 0, lrm[1] = N - 1, lrm[2] = (lrm[0] + lrm[1]) / 2;
  for (int k = 0; k < 3; ++k) {
    success_lrm[k] = false;
  }
  while (lrm[0] != lrm[2]) {
    for (int k = 0; k < 3; ++k) {
      moved_lrm[k] = lrm[k];
    }
    for (int q = 0; q < Q; ++q) {
      if (d_i[q] == 'L') {
        if (lrm[0] == 0 && lrm[1] == N - 1) {
          for (int i = 0; i < 3; ++i)
            move_left(lrm, moved_lrm, success_lrm, i, t_i[q], s, "LeftSideOut");
        } else {
          move_left(lrm, moved_lrm, success_lrm, 2, t_i[q], s, "LeftSideOut");
          if (success_lrm[2]) break;
        }
      } else {
        if (lrm[0] == 0 && lrm[1] == N - 1) {
          for (int i = 0; i < 3; ++i)
            move_right(lrm, moved_lrm, success_lrm, i, t_i[q], s, "LeftSideOut",
                       N);
        } else {
          move_right(lrm, moved_lrm, success_lrm, 2, t_i[q], s, "LeftSideOut",
                     N);
          if (success_lrm[2]) break;
        }
      }
    }
    if (success_lrm[0] && success_lrm[1] && success_lrm[2]) {
      max_idx = -1;
      min_idx = N;
      break;
    } else {
      if (success_lrm[0] && success_lrm[2] && !success_lrm[1]) {
        lrm[0] = lrm[2];
        success_lrm[0] = success_lrm[2];
        max_idx = lrm[2];
      } else if (success_lrm[0] && !success_lrm[2] && !success_lrm[1]) {
        lrm[1] = lrm[2];
        success_lrm[1] = success_lrm[2];
        max_idx = lrm[0];
      } else {
        break;
      }
      lrm[2] = (lrm[0] + lrm[1]) / 2;
      success_lrm[2] = false;
    }
  }
  lrm[0] = 0, lrm[1] = N - 1, lrm[2] = (lrm[0] + lrm[1]) / 2;
  for (int k = 0; k < 3; ++k) {
    success_lrm[k] = false;
  }
  while (lrm[0] != lrm[2]) {
    for (int k = 0; k < 3; ++k) {
      moved_lrm[k] = lrm[k];
    }
    for (int q = 0; q < Q; ++q) {
      if (d_i[q] == 'L') {
        if (lrm[0] == 0 && lrm[1] == N - 1) {
          for (int i = 0; i < 3; ++i)
            move_left(lrm, moved_lrm, success_lrm, i, t_i[q], s,
                      "RightSideOut");
        } else
          move_left(lrm, moved_lrm, success_lrm, 2, t_i[q], s, "RightSideOut");
      } else {
        if (lrm[0] == 0 && lrm[1] == N - 1) {
          for (int i = 0; i < 3; ++i)
            move_right(lrm, moved_lrm, success_lrm, i, t_i[q], s,
                       "RightSideOut", N);
        } else
          move_right(lrm, moved_lrm, success_lrm, 2, t_i[q], s, "RightSideOut",
                     N);
      }
    }
    if (success_lrm[0] && success_lrm[1] && success_lrm[2]) {
      max_idx = -1;
      min_idx = N;
      break;
    } else {
      if (!success_lrm[0] && success_lrm[2] && success_lrm[1]) {
        lrm[1] = lrm[2];
        success_lrm[1] = success_lrm[2];
        min_idx = lrm[2];
      } else if (!success_lrm[0] && !success_lrm[2] && success_lrm[1]) {
        lrm[0] = lrm[2];
        success_lrm[0] = success_lrm[2];
        min_idx = lrm[1];
      } else {
        break;
      }
      lrm[2] = (lrm[0] + lrm[1]) / 2;
      success_lrm[2] = false;
    }
  }
  cout << N - (max_idx + 1 + N - 1 - min_idx + 1) << endl;
  return 0;
}
