#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int inp(char c) {
  if (c == 'R') return 0;
  if (c == 'P') return 1;
  if (c == 'S') return 2;
}
int t[3][N];
int upd(int i, int p, int v) {
  for (; p < N; p += p & -p) t[i][p] += v;
  return 1;
}
int get(int i, int p) {
  int res = 0;
  for (; p > 0; p -= p & -p) res += t[i][p];
  return res;
}
int get(int i, int l, int r) { return get(i, r) - get(i, l - 1); }
int n, q;
string s;
int FullC(int i, bool Pre) {
  int L = 0, R = n + 1;
  while (L < R) {
    int M = (L + R) / 2;
    int l = Pre ? 1 : M;
    int r = Pre ? M : n;
    if ((get(i, l, r) == r - l + 1) != Pre)
      R = M;
    else
      L = M + 1;
  }
  return L;
}
int First(int i, bool Pre) {
  int L = 0, R = n + 1;
  while (L < R) {
    int M = (L + R) / 2;
    int l = Pre ? 1 : M;
    int r = Pre ? M : n;
    if ((get(i, l, r) > 0) == Pre)
      R = M;
    else
      L = M + 1;
  }
  return L;
}
int work() {
  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (get(i, n) == n) return n;
    if (get(i, n) == 0) continue;
    int j = (i + 2) % 3;
    if (get(j, n)) {
      ans += get(i, n);
      ans -= get(i, FullC(i, 1), FullC(i, 0) - 1);
      ans += get(i, First(j, 1), First(j, 0) - 1);
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> s;
  s = "#" + s;
  for (int i = 1; i <= n; ++i) upd(inp(s[i]), i, 1);
  cout << work() << "\n";
  while (q--) {
    int i;
    cin >> i;
    upd(inp(s[i]), i, -1);
    cin >> s[i];
    upd(inp(s[i]), i, 1);
    cout << work() << "\n";
  }
}
