import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, Q) = (input[0], input[1])
let s = readLine()!.characters.map{String($0)}
var arr = [Int](repeating: 1, count: N)

for _ in 0..<Q {
    let input = readStringSplit(by: " ")
    let t = input[0]
    let d = input[1]
    for i in 0..<s.count {
        if s[i] == t {
            if d == "L" {
                if i > 0 {
                    arr[i-1] += arr[i]
                }
            } else {
                if i < N-1 {
                    arr[i+1] += arr[i]
                }
            }
            arr[i] = 0
        }
    }
}

print(arr.reduce(0){$0 + $1})