#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
inline void read(int &qwq) {
  char ch = getchar();
  int f = 1;
  qwq = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') qwq = qwq * 10 + ch - '0', ch = getchar();
  qwq *= f;
}
set<int> pos[3];
int n, q, a[200050], sum[200050 << 2][3];
char opt[200050];
int tr(char x) { return x == 'R' ? 0 : (x == 'P' ? 1 : 2); }
void clear(int u) { sum[u][0] = sum[u][1] = sum[u][2] = 0; }
void update(int u) {
  for (register int i = 0; i <= 2; ++i)
    sum[u][i] = sum[u << 1][i] + sum[u << 1 | 1][i];
}
void build(int u, int l, int r) {
  if (l == r) return (void)(clear(u), sum[u][a[l]] = 1);
  build(u << 1, l, ((l + r) >> 1)), build(u << 1 | 1, ((l + r) >> 1) + 1, r);
  update(u);
}
void change(int u, int l, int r, int x) {
  if (l == r) return (void)(clear(u), sum[u][a[l]] = 1);
  if (x <= ((l + r) >> 1))
    change(u << 1, l, ((l + r) >> 1), x);
  else
    change(u << 1 | 1, ((l + r) >> 1) + 1, r, x);
  update(u);
}
int query(int u, int l, int r, int tl, int tr, int ty) {
  if (tl > tr) return 0;
  if (tl <= l && r <= tr) return sum[u][ty];
  int ret = 0;
  if (tl <= ((l + r) >> 1)) ret = query(u << 1, l, ((l + r) >> 1), tl, tr, ty);
  if (((l + r) >> 1) < tr)
    ret += query(u << 1 | 1, ((l + r) >> 1) + 1, r, tl, tr, ty);
  return ret;
}
int get(int c, int ty) {
  if (!ty)
    return pos[c].empty() ? n + 1 : *pos[c].begin();
  else
    return pos[c].empty() ? 0 : *--pos[c].end();
}
int calc() {
  int ret = 0;
  for (register int i = 0; i <= 2; ++i) {
    int beat = (i + 2) % 3, shit = (i + 1) % 3;
    if (pos[shit].empty())
      ret += query(1, 1, n, 1, n, i);
    else if (!pos[beat].empty()) {
      int ll1 = get(beat, 0), rr1 = get(beat, 1);
      int rr2 = get(shit, 0), ll2 = get(shit, 1);
      ret += query(1, 1, n, ll1 + 1, rr1 - 1, i);
      ret += query(1, 1, n, 1, rr2 - 1, i);
      ret += query(1, 1, n, ll2 + 1, n, i);
      ret -= query(1, 1, n, ll1 + 1, rr2 - 1, i) +
             query(1, 1, n, ll2 + 1, rr1 - 1, i);
    }
  }
  return ret;
}
int main() {
  read(n), read(q);
  scanf("%s", opt + 1);
  for (register int i = 1; i <= n; ++i) a[i] = tr(opt[i]), pos[a[i]].insert(i);
  build(1, 1, n);
  cout << calc() << endl;
  int w;
  while (q--) {
    read(w), scanf("%s", opt);
    pos[a[w]].erase(w), a[w] = tr(opt[0]), pos[a[w]].insert(w),
                        change(1, 1, n, w);
    cout << calc() << endl;
  }
  return 0;
}
