n players are going to play a rock-paper-scissors tournament. As you probably know, in a one-on-one match of rock-paper-scissors, two players choose their shapes independently. The outcome is then determined depending on the chosen shapes: "paper" beats "rock", "rock" beats "scissors", "scissors" beat "paper", and two equal shapes result in a draw.

At the start of the tournament all players will stand in a row, with their numbers increasing from 1 for the leftmost player, to n for the rightmost player. Each player has a pre-chosen shape that they will use in every game throughout the tournament. Here's how the tournament is conducted:

  * If there is only one player left, he is declared the champion.
  * Otherwise, two adjacent players in the row are chosen arbitrarily, and they play the next match. The losing player is eliminated from the tournament and leaves his place in the row (with his former neighbours becoming adjacent). If the game is a draw, the losing player is determined by a coin toss.



The organizers are informed about all players' favoured shapes. They wish to find out the total number of players who have a chance of becoming the tournament champion (that is, there is a suitable way to choose the order of the games and manipulate the coin tosses). However, some players are still optimizing their strategy, and can inform the organizers about their new shapes. Can you find the number of possible champions after each such request?

Input

The first line contains two integers n and q — the number of players and requests respectively (1 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ q ≤ 2 ⋅ 10^5).

The second line contains a string of n characters. The i-th of these characters is "R", "P", or "S" if the player i was going to play "rock", "paper", or "scissors" before all requests respectively.

The following q lines describe the requests. The j-th of these lines contain an integer p_j and a character c_j meaning that the player p_j is going to use the shape described by the character c_j from this moment (1 ≤ p_j ≤ n).

Output

Print q + 1 integers r_0, …, r_q, where r_k is the number of possible champions after processing k requests.

Example

Input


3 5
RPS
1 S
2 R
3 P
1 P
2 P


Output


2
2
1
2
2
3
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class D {
	static PrintWriter out = new PrintWriter(System.out);

	static int N;
	static BIT[] bs;
	static int[] cur;
	static TreeSet<Integer> ps[];
	static final boolean debug = true;
	public static void main(String[] args) {
		FS in = new FS();
		N = in.nextInt();
		int Q = in.nextInt();
		bs = new BIT[3];
		for(int i = 0; i < 3; i++) bs[i] = new BIT(N);
		cur = new int[N];
		ps = new TreeSet[3];
		for(int i = 0; i < 3; i++) ps[i] = new TreeSet<Integer>();
		
		char inp[] = in.next().toCharArray();
		for(int i = 0; i < N; i++) {
			cur[i] = map(inp[i]);
			bs[cur[i]].update(i, 1);
			ps[cur[i]].add(i);
		}
		
		out.println(eval());
		for(int i = 0; i < Q; i++) {
			int index = in.nextInt()-1;
			int to = map(in.next().charAt(0));
			change(index, to);
			out.println(eval());
		}
	
		out.close();
	}
	
	static long eval() {
		boolean left[] = new boolean[3];
		boolean right[] = new boolean[3];
		PriorityQueue<Data> pq = new PriorityQueue<Data>();
		for(int i = 0; i < 3; i++) {
			if(!ps[i].isEmpty()) {
				pq.add(new Data(i, ps[i].first()));
				pq.add(new Data(i, ps[i].last()));
				right[i] = true;
			}
		}
		long res = 0;
		
		int l = 0;
		while(l < N) {
			int r = (pq.isEmpty() ? N-1 : pq.peek().id - 1);
			
			// Process values from [l, r] then special case (r+1)
			for(int i = 0; i < 3; i++) {
				boolean good = true;
				if(left[lose(i)] && !left[win(i)]) good = false;
				if(right[lose(i)] && !right[win(i)]) good = false;
				if(good) res += bs[i].sum(l,r);
			}
			
			// now special case r+1
			if(r != N-1) {
				int val = pq.peek().val;
				boolean good = true;
				if(left[lose(val)] && !left[win(val)]) good = false;
				if(right[lose(val)] && !right[win(val)]) good = false;
				if(good) res++;
			}
			
			while(!pq.isEmpty() && pq.peek().id == r+1) {
				Data d = pq.poll();
				left[d.val] = true;
				if(ps[d.val].last() == d.id) right[d.val] = false;
			}
			l = r+2;
		}
		
		
		
		return res;
	}
	static int win(int x) { return x == 0 ? 2 : x-1;}
	static int lose(int x) { return x == 2 ? 0 : x+1;}
	
	static class Data implements Comparable<Data>{
		int id, val;
		public Data(int vv, int ii) {
			val = vv;
			id = ii;
		}
		@Override
		public int compareTo(Data o) { return id-o.id;}
		@Override
		public String toString() { return "(v="+val+" id="+id+")";}
	}
	
	static void change(int id, int to) {
		bs[cur[id]].update(id, -1);
		ps[cur[id]].remove(id);
		
		bs[to].update(id, 1);
		ps[to].add(id);
		cur[id] = to;
	}
	
	static int map(char c) {
		return c == 'R' ? 0 : (c == 'P' ? 1 : 2);
	}
	
	//0-indexed
	static class BIT {
		int n;
		long bar[];
		public BIT(int nn){
			bar = new long[nn+1];
			Arrays.fill(bar, 0);
			n = nn;
		}
		public void update(int index, long val){
			index++;
			while(index <= n){
				bar[index] += val;
				index += Integer.lowestOneBit(index);
			}
		}
		public long sum(int index){
			index++;
			long ans = 0;
			while(index > 0){
				ans += bar[index];
				index -= Integer.lowestOneBit(index);
			}
			return ans;
		}
		public long sum(int a, int b) {
			if(a > b) return 0;
			return sum(b) - (a == 0 ? 0 : sum(a-1));
		}
	}
	
	static class FS{
		BufferedReader br;
		StringTokenizer st;
		public FS() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {st = new StringTokenizer(br.readLine());}
				catch(Exception e) { throw null;}
			}
			return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next());}
		double nextDouble() { return Double.parseDouble(next());}
		long nextLong() { return Long.parseLong(next());}
		int[] NIA(int n) {
			int r[] = new int[n];
			for(int i = 0; i < n; i++) r[i] = nextInt();
			return r;
		}
		long[] NLA(int n) {
			long r[] = new long[n];
			for(int i = 0; i < n; i++) r[i] = nextLong();
			return r;
		}
		char[][] grid(int r, int c){
			char res[][] = new char[r][c];
			for(int i = 0; i < r; i++) {
				char l[] = next().toCharArray();
				for(int j = 0; j < c; j++) {
					res[i][j] = l[j];
				}
			}
			return res;
		}
	}
	
}
