#include <bits/stdc++.h>
using namespace std;
int n, m, a[200009], c[3][200009], ch[209];
char s[200009];
set<int> S[3];
int read() {
  int x = 0;
  char ch = getchar();
  bool flag = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return flag ? -x : x;
}
long long readll() {
  long long x = 0;
  char ch = getchar();
  bool flag = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return flag ? -x : x;
}
void ins(int *c, int x, int y) {
  for (; x <= n; x += x & -x) c[x] += y;
}
int qry(int *c, int x) {
  int ans = 0;
  for (; x; x ^= x & -x) ans += c[x];
  return ans;
}
int getsum(int *c, int x, int y) {
  if (x > y) return 0;
  return qry(c, y) - qry(c, x - 1);
}
void solve() {
  int i, ans = 0;
  for (i = 0; i < 3; i++) {
    int x = S[(i + 1) % 3].size();
    if (!x)
      ans += S[i].size();
    else {
      if (!S[(i + 2) % 3].size()) continue;
      int l = *(S[(i + 1) % 3].begin()), r = *(S[(i + 1) % 3].rbegin());
      int u = *(S[(i + 2) % 3].begin()), v = *(S[(i + 2) % 3].rbegin());
      ans += getsum(c[i], u, v) + getsum(c[i], 1, min(l, u)) +
             getsum(c[i], max(r, v), n);
    }
  }
  printf("%d\n", ans);
}
int main() {
  ch['R'] = 0;
  ch['P'] = 1;
  ch['S'] = 2;
  scanf("%d%d%s", &n, &m, s + 1);
  int i;
  for (i = 1; i <= n; i++) {
    a[i] = ch[s[i]];
    ins(c[a[i]], i, 1);
    S[a[i]].insert(i);
  }
  solve();
  while (m--) {
    scanf("%d%s", &i, s);
    int x = ch[s[0]];
    S[a[i]].erase(i);
    ins(c[a[i]], i, -1);
    a[i] = x;
    S[x].insert(i);
    ins(c[x], i, 1);
    solve();
  }
  return 0;
}
