#include <bits/stdc++.h>
using namespace std;
const int nmax = 200005;
int n, q, i, p;
int ans[nmax], poz[nmax];
char v[nmax], val[nmax];
int m[1000];
string s;
struct aib_meu {
  int aib[nmax];
  inline int lbit(int x) { return ((x ^ (x - 1)) & x); }
  int compute(int poz) {
    int ret = 0;
    for (int idx = poz; idx > 0; idx -= lbit(idx)) ret += aib[idx];
    return ret;
  }
  void update(int poz, int val) {
    for (int idx = poz; idx <= n; idx += lbit(idx)) aib[idx] += val;
  }
  int find_kth(int k) {
    int ret = 0, s = 0;
    for (int p = 17; p >= 0; p--)
      if (ret + (1 << p) <= n && s + aib[ret + (1 << p)] < k) {
        ret += (1 << p);
        s += aib[ret];
      }
    ret++;
    return ret;
  }
} A[3];
void calc(int wh) {
  int l1, l2, r1, r2, ct1, ct2;
  l1 = A[1].find_kth(1);
  r1 = A[1].find_kth(A[1].compute(n));
  l2 = A[2].find_kth(1);
  r2 = A[2].find_kth(A[2].compute(n));
  ct1 = A[1].compute(n);
  ct2 = A[2].compute(n);
  if (!ct1) {
    ans[wh] += A[0].compute(n);
    return;
  }
  if (l1 <= n && ct2) ans[wh] += (A[0].compute(min(l1, r2)));
  if (ct1 && ct2 && l2 <= n)
    ans[wh] += (A[0].compute(n) - A[0].compute(max(r1, l2)));
  if (max(l1, l2) <= n && max(l1, l2) <= min(r1, r2))
    ans[wh] += (A[0].compute(min(r1, r2)) - A[0].compute(max(l1, l2)));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  for (i = 1; i <= q; i++) {
    cin >> poz[i] >> val[i];
  }
  for (int cnt = 0; cnt < 3; cnt++) {
    if (cnt == 0) {
      m['R'] = 0;
      m['P'] = 1;
      m['S'] = 2;
    }
    if (cnt == 1) {
      m['P'] = 0;
      m['S'] = 1;
      m['R'] = 2;
    }
    if (cnt == 2) {
      m['S'] = 0;
      m['R'] = 1;
      m['P'] = 2;
    }
    for (i = 1; i <= n; i++) {
      v[i] = s[i - 1];
    }
    for (int j = 0; j < 3; j++)
      for (i = 1; i <= n; i++) A[j].aib[i] = 0;
    for (i = 1; i <= n; i++) A[m[v[i]]].update(i, 1);
    calc(0);
    for (i = 1; i <= q; i++) {
      p = poz[i];
      A[m[v[p]]].update(p, -1);
      v[p] = val[i];
      A[m[v[p]]].update(p, 1);
      calc(i);
    }
  }
  for (i = 0; i <= q; i++) cout << ans[i] << '\n';
  return 0;
}
