#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200007;
struct BIT {
  int ar[MAXN];
  BIT() { memset(ar, 0, sizeof ar); }
  void add(int idx, int v) {
    while (idx < MAXN) {
      ar[idx] += v;
      idx += idx & (-idx);
    }
  }
  int query(int idx) {
    int ans = 0;
    while (idx > 0) {
      ans += ar[idx];
      idx -= idx & (-idx);
    }
    return ans;
  }
  int range(int l, int r) {
    if (l > r) return 0;
    return query(r) - query(l - 1);
  }
} beet[3];
char shape[MAXN];
int getShape(char c) {
  if (c == 'R') return 0;
  if (c == 'P') return 1;
  if (c == 'S') return 2;
  assert(false);
}
set<int> st[3];
int n;
int enemy(int u) { return (u + 1) % 3; }
int other(int u, int v) {
  if (u != 0 && v != 0) return 0;
  if (u != 1 && v != 1) return 1;
  if (u != 2 && v != 2) return 2;
}
int calculate(int u) {
  int e = enemy(u);
  if (st[e].empty()) {
    return beet[u].query(n);
  }
  int el = *st[e].begin();
  auto it = st[e].end();
  it--;
  int er = *it;
  int o = other(u, e);
  if (st[o].empty()) {
    return 0;
  }
  int ol = *st[o].begin();
  auto jt = st[o].end();
  jt--;
  int oor = *jt;
  int ans = 0;
  ans += beet[u].range(1, min(el, oor));
  ans += beet[u].range(max(er, ol), n);
  ans += beet[u].range(max(el, ol), min(er, oor));
  return ans;
}
int findAns() {
  int x = calculate(0);
  int y = calculate(1);
  int z = calculate(2);
  return x + y + z;
}
void change(int idx, int from, int to) {
  if (from == to) return;
  st[from].erase(idx);
  beet[from].add(idx, -1);
  st[to].insert(idx);
  beet[to].add(idx, 1);
}
int main() {
  int q;
  scanf("%d %d", &n, &q);
  scanf("%s", shape + 1);
  for (int i = 1; i <= n; i++) {
    st[getShape(shape[i])].insert(i);
    beet[getShape(shape[i])].add(i, 1);
  }
  printf("%d\n", findAns());
  while (q--) {
    int p;
    char c;
    scanf("%d %c", &p, &c);
    change(p, getShape(shape[p]), getShape(c));
    shape[p] = c;
    printf("%d\n", findAns());
  }
  return 0;
}
