#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct BIT {
  int n;
  vector<int> bit;
  BIT(int _n = 0) {
    n = _n;
    bit.assign(n + 5, 0);
  }
  void update(int pos, int val) {
    for (; pos <= n; pos += pos & -pos) bit[pos] += val;
  }
  int getsum(int pos) {
    int res = 0;
    for (; pos; pos -= pos & -pos) res += bit[pos];
    return res;
  }
};
BIT bit[3];
set<int> pos[3];
int a[N];
int n, q;
int fix(char c) {
  if (c == 'R') return 0;
  if (c == 'S') return 1;
  return 2;
}
int getans() {
  int res = 0;
  for (int x = 0; x < 3; x++)
    if (pos[x].size()) {
      int y = (x + 1) % 3;
      int z = (x + 2) % 3;
      if (!pos[y].size())
        res += n * (!pos[z].size());
      else {
        res += pos[x].size();
        if (pos[z].size()) {
          int l = *pos[y].begin();
          int r = *prev(pos[y].end());
          int u = *pos[z].begin();
          int v = *prev(pos[z].end());
          if (r < v) res -= bit[x].getsum(v) - bit[x].getsum(r - 1);
          if (u < l) res -= bit[x].getsum(l) - bit[x].getsum(u - 1);
        }
      }
    }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 0; i < 3; i++) bit[i] = BIT(n);
  for (int i = 1; i <= n; i++) {
    char c;
    cin >> c;
    a[i] = fix(c);
    pos[a[i]].insert(i);
    bit[a[i]].update(i, 1);
  }
  cout << getans() << "\n";
  while (q--) {
    int i;
    char c;
    cin >> i >> c;
    pos[a[i]].erase(i);
    bit[a[i]].update(i, -1);
    a[i] = fix(c);
    pos[a[i]].insert(i);
    bit[a[i]].update(i, 1);
    cout << getans() << "\n";
  }
  return 0;
}
