#include <bits/stdc++.h>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printwe(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printbe(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...) {}
template <ostream& out = cout, class... T>
void printdu(T&&...){};
template <class S, class T>
istream& operator>>(istream& in, pair<S, T>& p) {
  return in >> p.first >> p.second;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& e : v) {
    in >> e;
  }
  return in;
}
template <class T>
istream& operator>>(istream& in, deque<T>& v) {
  for (auto& e : v) {
    in >> e;
  }
  return in;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  deque<char> s(n);
  cin >> s;
  vector<pair<char, char>> tds(q);
  cin >> tds;
  printde(s, tds);
  for (int i = tds.size() - 1; i >= 0; i--) {
    auto& td = tds[i];
    if (td.second == 'L') {
      if (s.front() == td.first) {
        s.pop_front();
      }
    } else {
      if (s.back() == td.first) {
        s.pop_back();
      }
    }
    printde(s);
  }
  cout << s.size() << '\n';
}
