import std.stdio, std.string, std.conv, std.algorithm, std.numeric, std.array, std.range;

void main() {
  long[][char] char_map;
  long n, q;
  readf("%d %d\n", &n, &q);
  auto s = readln.strip;
  char[] ts = new char[](q);
  char[] ds = new char[](q);

  foreach (i; 0..q) {
    readf("%c %c\n", &ts[i], &ds[i]);
  }

  foreach (i, c; s) {
    if (c !in char_map) {
      char_map[c] = [];
    }
    char_map[c] ~= cast(long)i;
  }

  long[] xs = new long[](n);
  foreach (ref x; xs) {
    x = 1;
  }

  foreach (i; 0..q) {
    if (ts[i] !in char_map) {
      continue;
    }
    long[] ps = char_map[ts[i]];
    if (ds[i] == 'L') {
      foreach (p; ps) {
        auto buf = xs[p];
        xs[p] = 0;
        if (p-1 >= 0) {
          xs[p-1] += buf;
        }
      }
    } else {
      foreach_reverse (p; ps) {
        auto buf = xs[p];
        xs[p] = 0;
        if (p+1 < n) {
          xs[p+1] += buf;
        }
      }
    }
  }

  long res = sum(xs);
  writeln(res);


}
