#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<char>> A;
  vector<int> gol;
  vector<char> ON;
  int counter = 0;
  for (int i = 0; i < n; i++) {
    char B;
    cin >> B;
    ON.push_back(B);
  }
  for (int i = 0; i < q; i++) {
    vector<char> copy;
    char rex, rex1;
    cin >> rex >> rex1;
    copy.push_back(rex);
    copy.push_back(rex1);
    A.push_back(copy);
  }
  for (int i = 0; i < n; i++) {
    gol.push_back(1);
  }
  for (int i = 0; i < q; i++) {
    for (int s = 0; s < n; s++) {
      if (A[i][0] == ON[s]) {
        if (A[i][0] == 'L' && s != 0) {
          gol[s]--;
          gol[s - 1]++;
        } else if (A[i][0] == 'R' && s + 1 != n) {
          gol[s]--;
          gol[s + 1]++;
        } else {
          gol[s]--;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int kari;
    kari = gol[i];
    counter += kari;
  }
  cout << counter;
}
