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.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int Q = sc.nextInt();
    	char[] s = sc.next().toCharArray();

    	char[] t = new char[Q];
    	char[] d = new char[Q];
    	for(int i=0; i<Q; i++) {
    		t[i] = sc.next().charAt(0);
    		d[i] = sc.next().charAt(0);
    	}

    	int[] lastLeft = new int[N];
    	for(int i=0; i<N; i++) {
    		lastLeft[i] = -1;
    	}
    	int idx = 0;
    	for(int i=Q-1; i>=0; i--) {
    		if(idx == N) break;
    		if(t[i] == s[idx] && d[i] == 'L') {
    			lastLeft[idx] = i;
    			idx++;
    		} else if(idx != 0 && t[i] == s[idx-1] && d[i] == 'R') {
    			int tmp = idx;
    			for(int j=i+1; j<=lastLeft[idx-1]; j++) {
    				if(tmp == idx-1) {
    					break;
    				}
    				if(tmp == N || j == lastLeft[idx-1]) {
    					lastLeft[idx-1] = -1;
    					idx--;
    					break;
    				}
    				if(t[j] == s[tmp]) {
    					if(d[j] == 'L') {
    						tmp--;
    					} else {
    						tmp++;
    					}
    				}
    			}
    		}
    	}

    	int ans = 0;
    	for(int i=0; i<N; i++) {
    		if(lastLeft[i] != -1) ans++;
    	}

    	int[] lastRight = new int[N];
    	for(int i=0; i<N; i++) {
    		lastRight[i] = -1;
    	}
    	idx = N-1;
    	for(int i=Q-1; i>=0; i--) {
    		if(idx == -1) break;
    		if(t[i] == s[idx] && d[i] == 'R') {
    			lastRight[idx] = i;
    			idx--;
    		} else if(idx != N-1 && t[i] == s[idx+1] && d[i] == 'L') {
    			int tmp = idx;
    			for(int j=i+1; j<=lastRight[idx+1]; j++) {
    				if(tmp == idx+1) {
    					break;
    				}
    				if(tmp == -1 || j == lastRight[idx+1]) {
    					lastRight[idx+1] = -1;
    					idx++;
    					break;
    				}
    				if(t[j] == s[tmp]) {
    					if(d[j] == 'L') {
    						tmp--;
    					} else {
    						tmp++;
    					}
    				}
    			}
    		}
    	}

    	for(int i=0; i<N; i++) {
    		if(lastRight[i] != -1) ans++;
    	}
    	if(ans > N) ans = N;
    	System.out.println(N - ans);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
