num = [int(i) for i in input().split(" ")]
map_ = [i for i in input()]
golem = [1 for i in range(len(map_))]
for i in range(len(map_) +1):
    magic = [i for i in input().split(" ")]
    lr = magic[1]
    place = [i for i,x in enumerate(map_) if x == magic[0]]
    for j in place:
        if j == 0:
            golem[j] = 0
        elif j == "L":
            golem[j -1] += golem[j]
        else:
            golem[j + 1] += golem[j]
        golem[j] = 0
print(sum(golem))