#include <bits/stdc++.h>
using namespace std;
char mps[255];
set<int> pos[3];
int SEGTREE[3][200005 * 4];
char s[200005];
void update(int *seg, int pos, int l, int r, int ind, int val) {
  if (l == r) {
    seg[pos] += val;
    return;
  }
  int mid = (l + r) / 2;
  if (ind <= mid)
    update(seg, pos * 2, l, mid, ind, val);
  else
    update(seg, pos * 2 + 1, mid + 1, r, ind, val);
  seg[pos] = seg[pos * 2] + seg[pos * 2 + 1];
}
int query(int *seg, int pos, int l, int r, int ql, int qr) {
  if (r < ql || qr < l) {
    return 0;
  }
  if (ql <= l && r <= qr) {
    return seg[pos];
  }
  int mid = (l + r) / 2;
  return query(seg, pos * 2, l, mid, ql, qr) +
         query(seg, pos * 2 + 1, mid + 1, r, ql, qr);
}
int getQuery(int id, int n) {
  int opId = (id + 1) % 3, weakID = (id + 2) % 3;
  if (pos[opId].size() == 0) {
    return pos[id].size();
  }
  if (pos[weakID].size() == 0 || pos[id].size() == 0) {
    return 0;
  }
  int ret = 0;
  int firstEnemy = *pos[opId].begin(), lastEnemy = *prev(pos[opId].end());
  int firstWeak = *pos[weakID].begin(), lastWeak = *prev(pos[weakID].end());
  int index;
  if (firstEnemy <= lastWeak) {
    index = firstEnemy;
  } else {
    index = lastWeak;
  }
  ret += query(SEGTREE[id], 1, 1, n, 1, index);
  int l = max(firstEnemy, firstWeak);
  int r = min(lastEnemy, lastWeak);
  if (l < r) {
    ret += query(SEGTREE[id], 1, 1, n, l, r);
  }
  if (firstWeak <= lastEnemy) {
    index = lastEnemy;
  } else {
    index = firstWeak;
  }
  ret += query(SEGTREE[id], 1, 1, n, index, n);
  return ret;
}
int getTotal(int n) { return getQuery(0, n) + getQuery(1, n) + getQuery(2, n); }
void solve() {
  int n, q;
  scanf("%d %d ", &n, &q);
  mps['R'] = 0;
  mps['P'] = 1;
  mps['S'] = 2;
  scanf(" %s ", s + 1);
  for (int i = 1; i <= n; ++i) {
    int id = mps[s[i]];
    pos[id].insert(i);
    update(SEGTREE[id], 1, 1, n, i, 1);
  }
  printf("%d\n", getTotal(n));
  char t;
  while (q--) {
    int index;
    int id;
    scanf("%d %c ", &index, &t);
    id = mps[s[index]];
    update(SEGTREE[id], 1, 1, n, index, -1);
    pos[id].erase(index);
    s[index] = t;
    id = mps[s[index]];
    update(SEGTREE[id], 1, 1, n, index, 1);
    pos[id].insert(index);
    printf("%d\n", getTotal(n));
  }
}
int main() {
  solve();
  return 0;
}
