#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char *argv[]) {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> qs(q);
  for (auto &p : qs) {
    cin >> p.first >> p.second;
  }
  vector<int> cnts(n, 1);
  int prev_idx_l = -1, prev_idx_r = -1, ans = 0;
  for (int i = 0; i < qs.size(); i++) {
    auto [t, d] = qs[i];
    if (t == s.front() && d == 'L') {
      int cnt = 1;
      for (int cur = i - 1, s_idx = 1; cur != prev_idx_l; cur--) {
        if (qs[cur].first == s[s_idx] && qs[cur].second == 'L') {
          cnt++;
          s_idx++;
        }
      }
      fill(cnts.begin(), cnts.begin() + cnt, 0);
      prev_idx_l = i;
    }
    if (t == s.back() && d == 'R') {
      int cnt = 1;
      for (int cur = i - 1, s_idx = s.size() - 2; cur != prev_idx_r; cur--) {
        if (qs[cur].first == s[s_idx] && qs[cur].second == 'R') {
          cnt++;
          s_idx--;
        }
      }
      fill(cnts.rbegin(), cnts.rbegin() + cnt, 0);
      prev_idx_r = i;
    }
    for (int i = 0; i < cnts.size(); ++i) {
      cout << cnts[i];
    }
    cout << '\n';
  }
  cout << accumulate(cnts.begin(), cnts.end(), 0) << '\n';
}
