#include <bits/stdc++.h>
using namespace std;
template <class T>
void printvec(const vector<T>& v) {
  for (auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}
template <class T>
void printtree(const vector<vector<T>>& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": ";
    printvec(tree[i]);
  }
}
template <class T, class U>
void printmap(const map<T, U>& mp) {
  for (auto x : mp) {
    cout << x.first << "=>" << x.second << endl;
  }
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1e9;
const long long MOD = 1000000007;
long long n, q;
string s;
vector<pair<char, char>> spells;
bool checkL(long long x) {
  for (long long i = 0; i < q; ++i) {
    char t, d;
    tie(t, d) = spells[i];
    if (s[x] == t) {
      if (d == 'L') {
        --x;
      } else {
        ++x;
      }
    }
    if (x < 0) {
      return false;
    }
    if (x >= n) {
      return true;
    }
  }
  return true;
}
bool checkR(long long x) {
  for (long long i = 0; i < q; ++i) {
    char t, d;
    tie(t, d) = spells[i];
    if (s[x] == t) {
      if (d == 'L') {
        --x;
      } else {
        ++x;
      }
    }
    if (x >= n) {
      return false;
    }
    if (x < 0) {
      return true;
    }
  }
  return true;
}
int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  spells.resize(q);
  for (long long i = 0; i < q; ++i) {
    cin >> spells[i].first >> spells[i].second;
  }
  long long left;
  {
    long long l = -1, r = n - 1;
    while (r - l > 1) {
      long long mid = (r + l) / 2;
      if (checkL(mid)) {
        r = mid;
      } else {
        l = mid;
      }
    }
    left = r;
  }
  long long right;
  {
    long long l = 0, r = n;
    while (r - l > 1) {
      long long mid = (r + l) / 2;
      if (checkR(mid)) {
        l = mid;
      } else {
        r = mid;
      }
    }
    right = l;
  }
  if (right >= left) {
    cout << (right - left + 1) << endl;
  } else {
    cout << 0 << endl;
  }
}
