#include <bits/stdc++.h>
using namespace std;
const int MN = 200005, P2 = (1 << 18), MTS = 2 * P2 + 5, inf = 1000000005,
          mod = 1000000007;
const long long INF = 1000000000000000005LL;
set<int> S[3];
int T[3][MTS];
char opis[MN];
map<char, int> rzepa;
int n;
int pie(set<int>& gruby) {
  if (!gruby.size()) return P2 - 5;
  auto it = gruby.begin();
  return (*it);
}
int ost(set<int>& gruby) {
  if (!gruby.size()) return 0;
  auto it = gruby.end();
  it--;
  return (*it);
}
int ask(int kto, int a, int b) {
  a += P2, b += P2;
  int ret = 0;
  while (a < b) {
    if (a & 1) ret += T[kto][a++];
    if (!(b & 1)) ret += T[kto][b--];
    a >>= 1, b >>= 1;
  }
  if (a == b) ret += T[kto][a];
  return ret;
}
void add(int kto, int pos, int v) {
  pos += P2;
  while (pos) {
    T[kto][pos] += v;
    pos >>= 1;
  }
}
int curMask = 0;
int win[100];
int ans() {
  int ret = n;
  if (__builtin_popcount(curMask) == 1) return n;
  if (__builtin_popcount(curMask) == 2) return S[win[curMask]].size();
  ret -= ask(0, pie(S[1]), pie(S[2]));
  ret -= ask(0, ost(S[2]), ost(S[1]));
  ret -= ask(1, pie(S[2]), pie(S[0]));
  ret -= ask(1, ost(S[0]), ost(S[2]));
  ret -= ask(2, pie(S[0]), pie(S[1]));
  ret -= ask(2, ost(S[1]), ost(S[0]));
  return ret;
}
int main() {
  rzepa['R'] = 0;
  rzepa['P'] = 1;
  rzepa['S'] = 2;
  win[3] = 1;
  win[5] = 0;
  win[6] = 2;
  int q;
  scanf("%d%d", &n, &q);
  scanf("%s", opis);
  for (int i = 0; i < n; ++i) {
    int kto = rzepa[opis[i]];
    curMask |= (1 << kto);
    add(kto, i + 1, 1);
    S[kto].insert(i + 1);
  }
  printf("%d\n", ans());
  while (q--) {
    int pos;
    char co[3];
    scanf("%d%s", &pos, co);
    int kto = rzepa[opis[pos - 1]];
    S[kto].erase(pos);
    if (!S[kto].size()) curMask -= (1 << kto);
    add(kto, pos, -1);
    opis[pos - 1] = co[0];
    kto = rzepa[opis[pos - 1]];
    S[kto].insert(pos);
    curMask |= (1 << kto);
    add(kto, pos, 1);
    printf("%d\n", ans());
  }
}
