#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
int n;
const int MAX_N = (1 << 18);
int nn, dat[3][2 * MAX_N - 1];
void init(int n_) {
  nn = 1;
  while (nn < n_) nn *= 2;
}
void update(int id, int k, int a) {
  k += nn - 1;
  dat[id][k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[id][k] = dat[id][k * 2 + 1] + dat[id][k * 2 + 2];
  }
}
int query(int id, int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b)
    return dat[id][k];
  else {
    int vl = query(id, a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = query(id, a, b, k * 2 + 2, (l + r) / 2, r);
    return vl + vr;
  }
}
int exile(int id) {
  if (query(id, 0, n, 0, 0, nn) == 0) return n;
  int k = 0;
  while (k < nn - 1) {
    int vl = dat[id][k * 2 + 1], vr = dat[id][k * 2 + 2];
    if (vl)
      k = k * 2 + 1;
    else
      k = k * 2 + 2;
  }
  return k - (nn - 1);
}
int exiri(int id) {
  if (query(id, 0, n, 0, 0, nn) == 0) return -1;
  int k = 0;
  while (k < nn - 1) {
    int vl = dat[id][k * 2 + 1], vr = dat[id][k * 2 + 2];
    if (vr)
      k = k * 2 + 2;
    else
      k = k * 2 + 1;
  }
  return k - (nn - 1);
}
int trans(char t) {
  if (t == 'R')
    return 0;
  else if (t == 'S')
    return 1;
  else
    return 2;
}
int le[3][2], ri[3][2];
int ans() {
  int res = 0;
  for (int i = 0; i < 3; i++) {
    le[i][0] = exile((i + 1) % 3);
    ri[i][0] = exiri((i + 1) % 3);
    le[i][1] = exile((i + 2) % 3);
    ri[i][1] = exiri((i + 2) % 3);
    if (le[i][0] <= le[i][1]) {
      res += query(i, 0, ri[i][0], 0, 0, nn);
      res += query(i, ri[i][1], n, 0, 0, nn);
      if (ri[i][1] <= ri[i][0]) res -= query(i, ri[i][1], ri[i][0], 0, 0, nn);
    } else if (ri[i][1] <= ri[i][0]) {
      res += query(i, 0, le[i][1], 0, 0, nn);
      res += query(i, le[i][0], n, 0, 0, nn);
      if (le[i][0] <= le[i][1]) res -= query(i, le[i][0], le[i][1], 0, 0, nn);
    } else {
      int lele = max(le[i][0], ri[i][1]);
      int riri = min(le[i][1], ri[i][0]);
      int lel = min(le[i][0], ri[i][1]);
      int rir = max(le[i][1], ri[i][0]);
      res += query(i, 0, riri, 0, 0, nn);
      res += query(i, lele, n, 0, 0, nn);
      res += query(i, lel, rir, 0, 0, nn);
    }
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> n >> q;
  init(n);
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    update(trans(s[i]), i, 1);
  }
  cout << ans() << endl;
  for (int i = 0; i < q; i++) {
    int x;
    char y;
    cin >> x >> y;
    x--;
    update(trans(s[x]), x, 0);
    s[x] = y;
    update(trans(s[x]), x, 1);
    cout << ans() << endl;
  }
  return 0;
}
