import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;

void main()
{
  int m = readln.chomp.split.back.to!int;
  string s = readln.chomp;
  int l = 0, r = 1;
  // bool[string] set;
  bool[ulong[2]] set;
  auto hasher = new RollingHash(s);
  foreach (i; 0..m) {
    string v = readln;
    auto f = function(char c, ref int w) {
      if (c == '+') {
        ++w;
      } else {
        --w;
      }
    };
    if (v[0] == 'L') {
      f(v[1], l);
    } else {
      f(v[1], r);
    }
    set[hasher.substr(l, r)] = true;
    // set[s[l..r]] = true;
  }
  writeln = set.length;
}

class RollingHash {
  enum long MOD1 = 1_000_000_007;
  enum long MOD2 = 1_000_000_009;
  enum long B1 = 1_009;
  enum long B2 = 1_007;

  ulong[] b1s, b2s;
  ulong[] array1;
  ulong[] array2;
  this(string s) {
    array1 ~= 0;
    array2 ~= 0;
    b1s ~= 1;
    b2s ~= 1;
    foreach (c; s) {
      array1 ~= ((array1.back + ulong(c)) * B1) % MOD1;
      array2 ~= ((array2.back + ulong(c)) * B2) % MOD2;
      b1s ~= (b1s.back * B1) % MOD1;
      b2s ~= (b2s.back * B2) % MOD2;
    }
  }
  ulong[2] substr(uint l, uint r)
  {
    ulong h1 = (array1[r] - ((b1s[r - l] * array1[l]) % MOD1) + MOD1) % MOD1;
    ulong h2 = (array2[r] - ((b2s[r - l] * array2[l]) % MOD2) + MOD2) % MOD2;
    return [h1, h2];
  }
}