#include <bits/stdc++.h>
using namespace std;
int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int get_ordered_golem_position(int pos, string s, string items, string orders) {
  char code = s[pos];
  for (int i = 0; i < items.size(); i++) {
    if (code == items[i]) {
      if (orders[i] == 'L')
        pos--;
      else
        pos++;
      code = s[pos];
    }
  }
  return pos;
}
int get_drop_position(int left, int right, string s, string t, string d,
                      char direction) {
  int position = left + (right - left) / 2;
  int moved_position = get_ordered_golem_position(position, s, t, d);
  if (direction == 'L') {
    if (right - left <= 1)
      return position;
    else if (moved_position < left)
      return get_drop_position(position, right, s, t, d, direction);
    else
      return get_drop_position(left, position, s, t, d, direction);
  } else {
    if (right - left <= 1)
      return position + 1;
    else if (moved_position < right)
      return get_drop_position(position, right, s, t, d, direction);
    else
      return get_drop_position(left, position, s, t, d, direction);
  }
  return 0;
}
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  string t(q, 'a'), d(q, 'a');
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int left_pos = get_drop_position(0, n, s, t, d, 'L');
  int right_pos = get_drop_position(0, n, s, t, d, 'R');
  int ans = n;
  ans -= left_pos - get_ordered_golem_position(left_pos, s, t, d);
  ans -= n - right_pos;
  cout << ans << endl;
  return 0;
}
int sum_digits(int num) {
  int rtn = 0;
  string num_str = to_string(num);
  for (int i = 0; i < num_str.size(); i++) {
    rtn += num_str[i] - '0';
  }
  return rtn;
}
template <class T>
vector<T> copy_vector(vector<T> vec) {
  vector<T> rtn;
  rtn.reserve(vec.size());
  copy(vec.begin(), vec.end(), back_inserter(rtn));
  return rtn;
}
