There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.

Snuke cast Q spells to move the golems.

The i-th spell consisted of two characters t_i and d_i, where d_i is `L` or `R`. When Snuke cast this spell, for each square with the character t_i, all golems on that square moved to the square adjacent to the left if d_i is `L`, and moved to the square adjacent to the right if d_i is `R`.

However, when a golem tried to move left from Square 1 or move right from Square N, it disappeared.

Find the number of golems remaining after Snuke cast the Q spells.

Constraints

* 1 \leq N,Q \leq 2 \times 10^{5}
* |s| = N
* s_i and t_i are uppercase English letters.
* d_i is `L` or `R`.

Input

Input is given from Standard Input in the following format:


N Q
s
t_1 d_1
\vdots
t_{Q} d_Q


Output

Print the answer.

Examples

Input

3 4
ABC
A L
B L
B R
A R


Output

2


Input

8 3
AABCBDBA
A L
B R
A R


Output

5


Input

10 15
SNCZWRCEWB
B R
R R
E R
W R
Z L
S R
Q L
W L
B R
C L
A L
N L
E R
Z L
S L


Output

3
import java.io.*;
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nq = in.readLineAsIntArray();
        final int N = nq[0];
        final int Q = nq[1];

        char[] s = in.readLine().toCharArray();

        Spell[] spells = new Spell[Q];
        for (int i = 0; i < Q; i++) {
            String[] sp = in.readLine().split(" ");
            spells[i] = new Spell(sp[0].charAt(0), sp[1].charAt(0));
        }

        int leftLow = 0;
        int leftHigh = N;
        while (leftLow < leftHigh) {
            int leftMid = (leftLow + leftHigh) / 2;
            if (posAfter(s, leftMid, spells) < 0) {
                leftLow = leftMid + 1;
            } else {
                leftHigh = leftMid;
            }
        }

        int rightLow = 0;
        int rightHigh = N;
        while (rightLow < rightHigh) {
            int rightMid = (rightLow + rightHigh) / 2;
            if (posAfter(s, rightMid, spells) >= N) {
                rightHigh = rightMid;
            } else {
                rightLow = rightMid + 1;
            }
        }
        int dead = leftLow + (N - rightHigh);
        System.out.println(N - dead);
    }

    private int posAfter(char[] map, int pos, Spell[] spells) {
        for (int q = 0; q < spells.length; q++) {
            Spell sp = spells[q];
            if (map[pos] == sp.t) {
                if (sp.direction == 'L') {
                    pos--;
                } else if (sp.direction == 'R') {
                    pos++;
                }
            }
            if (pos < 0 || pos >= map.length) {
                break;
            }
        }
        return pos;
    }

    class Spell {
        public final char t;
        public final char direction;

        public Spell(char t, char d) {
            this.t = t;
            this.direction = d;
        }

    }

    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}