#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int seg[4 * N][3];
char ss[] = "RPS";
char val[100];
int win[3] = {2, 0, 1};
int lose[3] = {1, 2, 0};
char S[N];
int n, q;
set<int> st[3];
void build(int s, int e, int idx) {
  if (s == e) {
    seg[idx][0] = seg[idx][1] = seg[idx][2] = 0;
    seg[idx][val[S[s]]] = 1;
    return;
  }
  build(s, ((s + e) >> 1), (idx << 1));
  build(((s + e) >> 1) + 1, e, (idx << 1) + 1);
  for (int i = 0; i < 3; i++)
    seg[idx][i] = seg[(idx << 1)][i] + seg[(idx << 1) + 1][i];
}
int l, r, Cur;
int getsum(int s, int e, int idx) {
  if (s > r || e < l) return 0;
  if (s >= l && e <= r) return seg[idx][Cur];
  return getsum(s, ((s + e) >> 1), (idx << 1)) +
         getsum(((s + e) >> 1) + 1, e, (idx << 1) + 1);
}
int Idx;
void update(int s, int e, int idx) {
  if (s > Idx || e < Idx) return;
  if (s == e) {
    seg[idx][0] = seg[idx][1] = seg[idx][2] = 0;
    seg[idx][val[(int)S[s]]] = 1;
    return;
  }
  update(s, ((s + e) >> 1), (idx << 1));
  update(((s + e) >> 1) + 1, e, (idx << 1) + 1);
  for (int i = 0; i < 3; i++)
    seg[idx][i] = seg[(idx << 1)][i] + seg[(idx << 1) + 1][i];
}
int last = 0;
inline int getleft(int idx, int i) {
  if (i < 0) return 0;
  last = n - 1;
  if ((int)st[lose[idx]].size() > 0) last = *(st[lose[idx]].begin());
  l = 0;
  r = min(i, last);
  Cur = idx;
  return getsum(0, n - 1, 1);
}
set<int>::iterator it;
inline int getright(int idx, int i) {
  if (i >= n) return 0;
  last = 0;
  if ((int)st[lose[idx]].size() > 0) {
    it = st[lose[idx]].end();
    it--;
    last = *it;
  }
  l = max(last, i);
  r = n - 1;
  Cur = idx;
  return getsum(0, n - 1, 1);
}
int tmp1, tmp2, ans = 0;
int getans() {
  ans = 0;
  for (int i = 0; i < 3; i++) {
    if ((int)st[i].size() == 0) continue;
    if ((int)st[i].size() == n) return n;
    tmp1 = n - 1;
    tmp2 = 0;
    if ((int)st[win[i]].size() > 0) {
      tmp1 = *(st[win[i]].begin());
      it = st[win[i]].end();
      it--;
      tmp2 = *it;
    }
    if (tmp1 <= tmp2) {
      l = tmp1;
      r = tmp2;
      Cur = i;
      ans += getsum(0, n - 1, 1);
      ans += getright(i, tmp2);
      ans += getleft(i, tmp1);
    }
  }
  return ans;
}
int main() {
  val[(int)'R'] = 0, val[(int)'P'] = 1, val[(int)'S'] = 2;
  scanf("%d%d", &n, &q);
  scanf("%s", S);
  build(0, n - 1, 1);
  for (int i = 0; i < n; i++) st[val[S[i]]].insert(i);
  printf("%d\n", getans());
  int idx;
  char tmp;
  while (q--) {
    scanf("%d %c", &idx, &tmp);
    idx--;
    st[val[S[idx]]].erase(st[val[S[idx]]].find(idx));
    st[val[(int)tmp]].insert(idx);
    S[idx] = tmp;
    Idx = idx;
    update(0, n - 1, 1);
    printf("%d\n", getans());
  }
  return 0;
}
