#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
pair<char, char> Method[200000];
int Gorem[200002];
set<char> unique_s;
map<char, vector<int> > char_place_dicts;
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    Method[i] = make_pair(t, d);
    unique_s.insert(t);
  }
  for (int i = 0; i < N; i++) {
    Gorem[i] = 1;
  }
  for (auto itr = unique_s.begin(); itr != unique_s.end(); ++itr) {
    vector<int> index_;
    for (int i = 0; i < N; i++) {
      if (*itr == s[i]) {
        index_.push_back(i);
      }
    }
    char_place_dicts[*itr] = index_;
  }
  for (int i = 0; i < Q; i++) {
    char char_ = Method[i].first;
    char direction = Method[i].second;
    if (unique_s.find(char_) == unique_s.end()) {
      continue;
    }
    int int_direction;
    if (direction == 'R') {
      int_direction = 1;
    } else {
      int_direction = -1;
    }
    for (int i = 0; i < char_place_dicts[char_].size(); i++) {
      int place = char_place_dicts[char_][i];
      if ((place + int_direction != -1) && (place + int_direction != N)) {
        Gorem[place + int_direction] += Gorem[place];
      }
      Gorem[place] = 0;
    }
  }
  int sum_ = 0;
  for (int i = 0; i < N; i++) {
    sum_ += Gorem[i];
  }
  cout << sum_ << endl;
  return 0;
}
