#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<char> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  vector<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  vector<int> count(N, 1);
  Q = 3;
  for (int i = 0; i < Q; i++) {
    if (d.at(i) == 'L') {
      for (int j = 0; j < N; j++) {
        if (t.at(i) == s.at(j)) {
          if (j != 0) {
            count.at(j - 1) += count.at(j);
          }
          count.at(j) = 0;
        }
      }
    }
    if (d.at(i) == 'R') {
      for (int j = N - 1; j >= 0; j--) {
        if (t.at(i) == s.at(j)) {
          if (j != N - 1) {
            count.at(j + 1) += count.at(j);
          }
          count.at(j) = 0;
        }
      }
    }
  }
  int answer = 0;
  for (int j = 0; j < N; j++) {
    answer += count.at(j);
  }
  cout << answer << endl;
  for (int i = 0; i < N; i++) {
    cout << count.at(i);
  }
}
