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;
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(int x);
inline void writeWord(const char *s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) c = getChar();
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
inline void readWord(char *s) {
  int c = readChar();
  while (c > 32) *s++ = c, c = getChar();
  *s = 0;
}
inline void writeDouble(double x, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  int t = (int)x;
  writeInt(t), x -= t;
  writeChar('.');
  for (int i = output_len - 1; i > 0; i--) {
    x *= 10;
    t = min(9, (int)x);
    writeChar('0' + t), x -= t;
  }
  x *= 10;
  t = min(9, (int)(x + 0.5));
  writeChar('0' + t);
}
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using ull = unsigned long long;
using pnt = complex<ld>;
istream &operator>>(istream &in, pnt &p) {
  ld a, b;
  in >> a >> b;
  p = {a, b};
  return in;
}
ld crs(pnt a, pnt b) { return a.real() * b.imag() - a.imag() * b.real(); }
ld dot(pnt a, pnt b) { return a.real() * b.real() + a.imag() * b.imag(); }
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18L;
const ld pi = acos(-1.0L);
const ld eps = 1e-9L;
const int di[] = {0, 1, -1, 0};
const int dj[] = {1, 0, 0, -1};
const int SQ = 1000;
const int LG = 21;
const int nax = 1e6 + 100;
const pii neu = make_pair(inf, -inf);
pii comb(pii a, pii b) {
  return make_pair(min(a.first, b.first), max(a.second, b.second));
}
struct segTree {
  int n;
  vector<pii> t;
  segTree(int n) : n(n), t(2 * n, neu) {}
  void upd(int v, pii x) {
    t[v += n] = x;
    for (v >>= 1; v; v >>= 1) t[v] = comb(t[v * 2], t[v * 2 + 1]);
  }
  pii get(int l, int r) {
    pii ret = neu;
    for (l += n, r += n; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
      if (l & 1) ret = comb(ret, t[l]);
      if (!(r & 1)) ret = comb(ret, t[r]);
    }
    return ret;
  }
};
struct fenwick {
  int n;
  vi t;
  fenwick(int n) : n(n), t(n, 0) {}
  void upd(int v, int x) {
    for (int i = v; i < n; i |= i + 1) t[i] += x;
  }
  int get(int v) {
    int ret = 0;
    for (int i = v; i >= 0; i = (i & (i + 1)) - 1) ret += t[i];
    return ret;
  }
  int get(int l, int r) {
    if (l > r) return 0;
    return get(r) - get(l - 1);
  }
};
int n, q;
string s;
int a[nax];
map<char, int> re;
int getAns(vector<segTree> &t, vector<fenwick> &f) {
  int ret = 0;
  pii _all = make_pair(-inf, inf);
  for (int i = 0; i < 3; i++) {
    pii g = t[i].get(0, n - 1);
    _all.first = max(_all.first, g.first);
    _all.second = min(_all.second, g.second);
  }
  for (int who = 0; who < 3; who++) {
    pii g = t[(who + 1) % 3].get(0, n - 1);
    if (g.first > g.second)
      ret += f[who].get(0, n - 1);
    else
      ret += f[who].get(
                 0, min(g.first - 1, t[(who + 2) % 3].get(0, n - 1).second)) +
             f[who].get(_all.first, _all.second) +
             f[who].get(max(t[(who + 2) % 3].get(0, n - 1).first, g.second + 1),
                        n - 1);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout.precision(12);
  cout << fixed;
  re['R'] = 0;
  re['P'] = 1;
  re['S'] = 2;
  cin >> n >> q >> s;
  vector<segTree> t(3, segTree(n));
  vector<fenwick> f(3, fenwick(n));
  for (int i = 0; i < n; i++)
    a[i] = re[s[i]], t[a[i]].upd(i, make_pair(i, i)), f[a[i]].upd(i, 1);
  cout << getAns(t, f) << '\n';
  while (q--) {
    int pos;
    char ch;
    cin >> pos >> ch;
    pos--;
    t[a[pos]].upd(pos, neu);
    f[a[pos]].upd(pos, -1);
    a[pos] = re[ch];
    t[a[pos]].upd(pos, make_pair(pos, pos));
    f[a[pos]].upd(pos, 1);
    cout << getAns(t, f) << '\n';
  }
}
