#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 9, lg = 19, MOD = 998244353, maxV = 1e3 + 9;
int T[3][maxN], n, q, arr[maxN], mp[129];
priority_queue<int> pqs[2][3];
string st;
int query(int w, int *T) {
  int ret = 0;
  for (w++; w > 0; w -= w & -w) ret += T[w];
  return ret;
}
int query(int l, int r, int *T) { return query(r - 1, T) - query(l - 1, T); }
void update(int w, int x, int *T) {
  for (w++; w <= n; w += w & -w) T[w] += x;
}
pair<int, int> getpa(int heroe, int mamon, priority_queue<int> *pqs) {
  if (pqs[mamon].empty()) return pair<int, int>(n, n);
  if (pqs[heroe].empty()) return pair<int, int>(0, pqs[mamon].top());
  return pair<int, int>(min(pqs[mamon].top(), pqs[heroe].top()),
                        pqs[mamon].top());
}
pair<int, int> gira(pair<int, int> x) {
  return pair<int, int>(n - x.second, n - x.first);
}
int mergpl(pair<int, int> one, pair<int, int> two, int *lT) {
  if (one > two) swap(one, two);
  if (two.first < one.second)
    return query(one.first, max(one.second, two.second), lT);
  return query(one.first, one.second, lT) + query(two.first, two.second, lT);
}
int countGood() {
  int ret = 0;
  for (int u = 0, offs = 0, mu = 1; u < 2; u++, offs = n - 1, mu = -1)
    for (int i = 0; i < 3; i++)
      while (pqs[u][i].size() && arr[offs + mu * pqs[u][i].top()] != i)
        pqs[u][i].pop();
  for (int i = 0; i < 3; i++) {
    int heroe = (i + 1) % 3, mamon = (i + 2) % 3;
    ret += query(n - 1, T[i]) - mergpl(getpa(heroe, mamon, pqs[0]),
                                       gira(getpa(heroe, mamon, pqs[1])), T[i]);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  mp['R'] = 1;
  mp['S'] = 2;
  cin >> n >> q >> st;
  for (int i = 0; i < n; i++) {
    arr[i] = mp[st[i]];
    pqs[0][arr[i]].push(i);
    pqs[1][arr[i]].push(n - 1 - i);
    update(i, 1, T[arr[i]]);
  }
  cout << countGood() << '\n';
  while (q--) {
    int pos;
    char c;
    cin >> pos >> c;
    pos--;
    update(pos, -1, T[arr[pos]]);
    arr[pos] = mp[c];
    update(pos, 1, T[arr[pos]]);
    pqs[0][arr[pos]].push(pos);
    pqs[1][arr[pos]].push(n - 1 - pos);
    cout << countGood() << '\n';
  }
}
