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;
template <typename FUNC>
struct ReturnType;
template <typename RT, typename... AT>
struct ReturnType<RT (*)(AT...)> {
  using type = RT;
};
template <typename FUNC>
struct SecondArgType;
template <typename RT, typename A1T, typename A2T, typename... AT>
struct SecondArgType<RT (*)(A1T, A2T, AT...)> {
  using type = A2T;
};
template <typename OPS>
class SegTree {
 public:
  using T = typename ReturnType<decltype(&OPS::combine)>::type;
  using UPD = typename SecondArgType<decltype(&OPS::update)>::type;
  SegTree(int n) : data(4 * n), n(n) {}
  SegTree(const vector<T> &a) : SegTree(a.size()) { doBld(a, 1, 0, n - 1); }
  T get(int l, int r) { return doGet(l, r, 1, 0, n - 1); }
  void upd(int i, UPD val) { doUpd(i, val, 1, 0, n - 1); }

 private:
  int n;
  vector<T> data;
  void doBld(const vector<T> &a, int v, int from, int to) {
    if (from == to) {
      data[v] = a[from];
    } else {
      int mid = (from + to) / 2;
      doBld(a, 2 * v, from, mid);
      doBld(a, 2 * v + 1, mid + 1, to);
      doRecalc(v);
    }
  }
  void doUpd(int i, UPD val, int v, int from, int to) {
    if (from < to) {
      int mid = (from + to) / 2;
      if (i <= mid) {
        doUpd(i, val, 2 * v, from, mid);
      } else {
        doUpd(i, val, 2 * v + 1, mid + 1, to);
      }
      doRecalc(v);
    } else {
      data[v] = OPS::update(data[v], val);
    }
  }
  T doGet(int l, int r, int v, int from, int to) {
    if (l <= from && to <= r) {
      return data[v];
    }
    int mid = (from + to) / 2;
    if (l > mid) {
      return doGet(l, r, 2 * v + 1, mid + 1, to);
    }
    if (mid + 1 > r) {
      return doGet(l, r, 2 * v, from, mid);
    }
    return OPS::combine(doGet(l, r, 2 * v, from, mid),
                        doGet(l, r, 2 * v + 1, mid + 1, to));
  }
  void doRecalc(int v) { data[v] = OPS::combine(data[2 * v], data[2 * v + 1]); }
};
struct SegTreeOps {
  static int combine(int a, int b) { return a + b; }
  static int update(int cur, int val) { return val; }
};
struct State {
  int n;
  SegTree<SegTreeOps> st;
  set<int> pos, neg;
  char chPos, chNeg;
  State(int n, char chPos, char chNeg)
      : n(n), st(n), chPos(chPos), chNeg(chNeg) {}
  int updCh(int i, char ch) {
    int val = 0;
    if (ch == chPos) {
      val = 1;
    } else if (ch == chNeg) {
      val = -1;
    }
    return upd(i, val);
  }
  int upd(int i, int val) {
    if (pos.count(i) > 0) {
      pos.erase(i);
    } else if (neg.count(i) > 0) {
      neg.erase(i);
    } else {
      st.upd(i, 0);
    }
    if (val == 1) {
      pos.insert(i);
    } else if (val == -1) {
      neg.insert(i);
    } else {
      st.upd(i, 1);
    }
    return calcRes();
  }
  int calcRes() {
    int tot = st.get(0, n - 1);
    if (neg.size() == 0) {
      return tot;
    }
    if (pos.size() == 0) {
      return 0;
    }
    int ans = tot;
    int leftPos = *pos.begin(), leftNeg = *neg.begin();
    if (leftNeg < leftPos) {
      ans -= st.get(leftNeg, leftPos);
    }
    int rightPos = *pos.rbegin(), rightNeg = *neg.rbegin();
    if (rightPos < rightNeg) {
      ans -= st.get(rightPos, rightNeg);
    }
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  string s;
  cin >> n >> m >> s;
  vector<State> all;
  all.emplace_back(n, 'P', 'R');
  all.emplace_back(n, 'S', 'P');
  all.emplace_back(n, 'R', 'S');
  int start = 0;
  for (int i = 0; i < n; i++) {
    for (auto &st : all) {
      int v = st.updCh(i, s[i]);
      if (i == n - 1) {
        start += v;
      }
    }
  }
  cout << start << "\n";
  for (int i = 0; i < m; i++) {
    int j;
    char ch;
    cin >> j >> ch;
    j--;
    int res = 0;
    for (auto &st : all) {
      res += st.updCh(j, ch);
    }
    cout << res << "\n";
  }
}
