#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int bi[3][N];
int n, q, i, x;
char c[10], d[N];
inline void add(int* a, int x, int v) {
  for (; x <= n; x += x & -x) a[x] += v;
}
inline int sum(int* a, int x) {
  int ans = 0;
  for (; x; x -= x & -x) ans += a[x];
  return ans;
}
inline int sum(int* a, int l, int r) {
  return l <= r ? sum(a, r) - sum(a, l - 1) : 0;
}
inline int idx(char c) { return c == 'S' ? 0 : (c == 'R' ? 1 : 2); }
set<int> s[3];
set<int>::iterator it;
inline int calc() {
  int ans = 0;
  for (i = 0; i < 3; ++i) {
    int x = (i + 1) % 3, y = (i + 2) % 3;
    int xx, yy, xxx, yyy;
    if (s[x].empty()) {
      ans += sum(bi[i], n);
      continue;
    }
    if (s[y].empty()) continue;
    xx = *s[x].begin();
    yy = *s[y].begin();
    if (yy < xx) {
      xx = *s[x].rbegin();
      yy = *s[y].rbegin();
      if (xx > yy)
        ans += sum(bi[i], xx + 1, n) + sum(bi[i], yy);
      else
        ans += sum(bi[i], n);
    } else {
      ans += sum(bi[i], 1, xx - 1);
      xxx = *s[x].rbegin();
      yyy = *s[y].rbegin();
      if (xxx < yyy)
        ans += sum(bi[i], yy, n);
      else
        ans += sum(bi[i], yy, yyy) + sum(bi[i], xxx, n);
    }
  }
  return ans;
}
int main() {
  scanf("%d%d%s", &n, &q, d + 1);
  for (i = 1; i <= n; ++i) {
    d[i] = idx(d[i]);
    s[d[i]].insert(i);
    add(bi[d[i]], i, 1);
  }
  printf("%d\n", calc());
  while (q--) {
    scanf("%d%s", &x, c);
    *c = idx(*c);
    add(bi[d[x]], x, -1);
    s[d[x]].erase(x);
    add(bi[*c], x, 1);
    s[*c].insert(x);
    d[x] = *c;
    printf("%d\n", calc());
  }
  return 0;
}
