#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[200010];
int pos[3][2], c[3][200010];
set<int> se[3];
inline int lowbit(int x) { return x & (-x); }
void add(int x, int w, int c[]) {
  for (int i = x; i <= n; i += lowbit(i)) c[i] += w;
}
int getsum(int x, int c[]) {
  int sum = 0;
  for (int i = x; i; i -= lowbit(i)) sum += c[i];
  return sum;
}
int calc() {
  if (se[0].size() == 0 && se[1].size() == 0) return se[2].size();
  if (se[0].size() == 0 && se[2].size() == 0) return se[1].size();
  if (se[1].size() == 0 && se[2].size() == 0) return se[0].size();
  if (se[0].size() == 0) return se[1].size();
  if (se[1].size() == 0) return se[2].size();
  if (se[2].size() == 0) return se[0].size();
  int ans = 0, l, r;
  for (int i = 0; i < 3; ++i) {
    l = pos[(i + 2) % 3][0];
    r = pos[(i + 1) % 3][0];
    if (l < r) ans += getsum(r, c[i]) - getsum(l, c[i]);
    l = pos[(i + 1) % 3][1];
    r = pos[(i + 2) % 3][1];
    if (l < r) ans += getsum(r, c[i]) - getsum(l, c[i]);
  }
  return n - ans;
}
int get_min(set<int> &se) {
  if (se.size() == 0) return 0;
  return *se.begin();
}
int get_max(set<int> &se) {
  if (se.size() == 0) return 0;
  auto it = se.end();
  --it;
  return *it;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", a + 1);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == 'R')
      a[i] = 0;
    else if (a[i] == 'S')
      a[i] = 1;
    else
      a[i] = 2;
    se[a[i]].insert(i);
    if (pos[a[i]][0] == 0) pos[a[i]][0] = i;
    pos[a[i]][1] = i;
    add(i, 1, c[a[i]]);
  }
  printf("%d\n", calc());
  int x, k;
  char st[10];
  for (int i = 1; i <= m; ++i) {
    scanf("%d%s", &x, st);
    if (st[0] == 'R')
      k = 0;
    else if (st[0] == 'S')
      k = 1;
    else
      k = 2;
    se[a[x]].erase(x);
    se[k].insert(x);
    pos[a[x]][0] = get_min(se[a[x]]);
    pos[a[x]][1] = get_max(se[a[x]]);
    pos[k][0] = get_min(se[k]);
    pos[k][1] = get_max(se[k]);
    add(x, -1, c[a[x]]);
    add(x, 1, c[k]);
    a[x] = k;
    printf("%d\n", calc());
  }
  return 0;
}
