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
#include <bits/stdc++.h>
using namespace std;
const int MAX = 210000;
const long long base = 1e9 + 7;
struct Node {
  int ns[3];
};
int pos[MAX][5];
Node stree[MAX * 4];
string sss;
int gstart = 0;
int gend = 1111;
static int count_tn = 0;
struct TNode {
  int root, nstart, nend, mid;
  TNode() {}
  TNode(int r, int ns, int ne) {
    root = r;
    nstart = ns;
    nend = ne;
    mid = (ns + ne) / 2;
  }
  TNode getLeft() const { return TNode(root * 2 + 1, nstart, mid); }
  TNode getRight() const { return TNode(root * 2 + 2, mid + 1, nend); }
};
TNode superRoot;
void refresh(Node& n0, Node& n1, Node& n2) {
  for (int i = 0; i < 3; ++i) {
    n0.ns[i] = n1.ns[i] + n2.ns[i];
  }
}
void refresh(int root, int left, int right) {
  refresh(stree[root], stree[left], stree[right]);
}
void init(int root, int nstart) {
  for (int i = 0; i < 3; ++i) {
    stree[root].ns[i] = 0;
  }
  char c = sss[nstart];
  int t;
  if (c == 'R')
    t = 0;
  else if (c == 'P')
    t = 1;
  else if (c == 'S')
    t = 2;
  stree[root].ns[t] = 1;
  return;
}
void buildt(const TNode& tn) {
  if (tn.nstart == tn.nend) {
    init(tn.root, tn.nstart);
    return;
  }
  auto tn0 = tn.getLeft();
  auto tn1 = tn.getRight();
  buildt(tn0);
  buildt(tn1);
  refresh(tn.root, tn0.root, tn1.root);
}
void update(const TNode& tn, int change) {
  if (change < tn.nstart || change > tn.nend) return;
  if (tn.nstart == tn.nend) {
    init(tn.root, tn.nstart);
    return;
  }
  auto tn0 = tn.getLeft();
  auto tn1 = tn.getRight();
  update(tn0, change);
  update(tn1, change);
  refresh(tn.root, tn0.root, tn1.root);
}
int query1(const TNode& tn, int s, bool le) {
  if (stree[tn.root].ns[s] == 0) return -1;
  if (tn.nstart == tn.nend) {
    return tn.nstart;
  }
  auto tn0 = tn.getLeft();
  auto tn1 = tn.getRight();
  if (le) {
    auto r1 = query1(tn0, s, le);
    if (r1 >= 0) return r1;
    auto r2 = query1(tn1, s, le);
    return r2;
  } else {
    auto r2 = query1(tn1, s, le);
    if (r2 >= 0) return r2;
    auto r1 = query1(tn0, s, le);
    return r1;
  }
}
int query0(const TNode& tn, int b1, int b2, int s) {
  if (b2 < tn.nstart || b1 > tn.nend) return 0;
  if (b1 <= tn.nstart && tn.nend <= b2) {
    return stree[tn.root].ns[s];
  }
  auto tn0 = tn.getLeft();
  auto tn1 = tn.getRight();
  auto r1 = query0(tn0, b1, b2, s);
  auto r2 = query0(tn1, b1, b2, s);
  return r1 + r2;
}
int n, q;
void work() {
  int tot = 0;
  bool mis = false;
  for (int i = 0; i < 3; ++i) {
    if (stree[0].ns[(i + 1) % 3] == 0) {
      tot += stree[0].ns[i];
      mis = true;
    }
  }
  if (mis) {
    cout << tot << '\n';
    return;
  }
  int tb[3], te[3];
  for (int i = 0; i < 3; ++i) {
    tb[i] = query1(superRoot, i, true);
    te[i] = query1(superRoot, i, false);
  }
  tot = n;
  for (int i = 0; i < 3; ++i) {
    int a = te[(i + 2) % 3];
    int b = te[(i + 1) % 3];
    if (a < b) {
      tot -= query0(superRoot, a, b, i);
    }
    a = tb[(i + 1) % 3];
    b = tb[(i + 2) % 3];
    if (a < b) {
      tot -= query0(superRoot, a, b, i);
    }
  }
  cout << tot << '\n';
}
void solve() {
  long long result = 0;
  cin >> n >> q;
  cin >> sss;
  superRoot = {0, 0, n - 1};
  buildt(superRoot);
  work();
  for (int i = 0; i < q; ++i) {
    int k;
    string s;
    cin >> k >> s;
    sss[k - 1] = s[0];
    update(superRoot, k - 1);
    work();
  }
  int ttt = count_tn;
  int x = 1;
}
int main() {
  const int inId = 0;
  const int outId = 0;
  if (inId > 0) {
    cerr << "redirect stdin to input " << inId << endl;
    string s = "input";
    s += to_string(inId);
    s += ".txt";
    auto r = freopen(s.c_str(), "r", stdin);
    if (r == nullptr) {
      cerr << "invalid input file " << s;
    }
  }
  if (outId > 0) {
    cerr << "redirect stdout to stdout " << outId << endl;
    string s = "stdout";
    s += to_string(outId);
    s += ".txt";
    auto r = freopen(s.c_str(), "w", stdout);
    if (r == nullptr) {
      cerr << "invalid output file " << s;
    }
  }
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  solve();
}
