#include <bits/stdc++.h>
using namespace std;
char s[200010];
int n, m, into[1000];
set<int> S[3];
int bit[200010][3];
int lowbit(int x) { return x & (-x); }
void update(int x, int z, int t) {
  for (x; x < 200010; x += lowbit(x)) bit[x][t] += z;
}
int ask(int x, int t) {
  int ans = 0;
  for (x; x; x -= lowbit(x)) ans += bit[x][t];
  return ans;
}
int calc(int x) {
  int y = (x + 1) % 3;
  int z = (x + 2) % 3;
  int ans = ask(200000, x);
  if (S[y].size() == 2) return ans;
  if (S[z].size() == 2) return 0;
  set<int>::iterator a = S[y].upper_bound(n);
  a--;
  set<int>::iterator b = S[z].upper_bound(n);
  b--;
  if (*a > *b) ans -= ask(*a, x) - ask(*b, x);
  a = S[y].lower_bound(1);
  b = S[z].lower_bound(1);
  if (*a < *b) ans -= ask(*b, x) - ask(*a, x);
  return ans;
}
int main(int argc, char const *argv[]) {
  scanf("%d%d", &n, &m);
  into['S'] = 0;
  into['R'] = 1;
  into['P'] = 2;
  scanf("%s", s + 1);
  for (int i = 0; i < 3; i++) S[i].insert(0), S[i].insert(n + 1);
  for (int i = 1; i <= n; i++) {
    S[into[s[i]]].insert(i);
    update(i, 1, into[s[i]]);
  }
  int op;
  char q[10];
  for (int i = 1; i <= m; i++) {
    printf("%d\n", calc(0) + calc(1) + calc(2));
    scanf("%d%s", &op, q);
    char y = q[0];
    S[into[s[op]]].erase(op);
    update(op, -1, into[s[op]]);
    s[op] = y;
    S[into[s[op]]].insert(op);
    update(op, 1, into[s[op]]);
  }
  printf("%d\n", calc(0) + calc(1) + calc(2));
  return 0;
}
