#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100, M = 3;
int n, q, dex, ans, f[N], good[M], bad[M], fen[N][M];
string s;
set<int> st[M];
inline void add(int dex, int type, int val) {
  for (; dex < N; dex += (dex & -dex)) fen[dex][type] += val;
}
inline int get(int dex, int type) {
  return (dex > 0 ? fen[dex][type] + get(dex ^ (dex & -dex), type) : 0);
}
inline void check(int l1, int r1, int l2, int r2, int type) {
  int l = max(l1, l2), r = min(r1, r2);
  if (r >= l) ans += get(r, type) - get(l - 1, type);
}
inline int solve() {
  ans = 0;
  for (int i = 0; i < M; i++) {
    if (st[i].empty())
      continue;
    else if (st[i].size() == n) {
      ans = n;
      break;
    }
    if (st[bad[i]].empty()) {
      ans += st[i].size();
      continue;
    } else if (st[good[i]].empty())
      continue;
    int a, b, A, B;
    a = (*st[bad[i]].begin()) - 1;
    auto x = st[good[i]].begin();
    b = (st[good[i]].empty() ? n + 1 : max(a + 1, *x));
    B = (*st[bad[i]].rbegin()) + 1;
    x = --st[good[i]].end();
    A = (st[good[i]].empty() ? 0 : min(*x, B - 1));
    check(0, a, 0, A, i);
    check(0, a, B, n, i);
    check(b, n, 0, A, i);
    check(b, n, B, n, i);
  }
  return ans;
}
inline void add_element(int dex) {
  add(dex, f[s[dex]], 1);
  st[f[s[dex]]].insert(dex);
}
inline void del_element(int dex) {
  add(dex, f[s[dex]], -1);
  st[f[s[dex]]].erase(dex);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  f['R'] = 0, f['P'] = 1, f['S'] = 2;
  for (int i = 0; i < M; i++) bad[i] = (i + 1) % M, good[i] = (i - 1 + M) % M;
  cin >> n >> q >> s;
  s = "#" + s;
  for (int i = 1; i <= n; i++) add_element(i);
  cout << solve() << '\n';
  while (q--) {
    cin >> dex;
    del_element(dex);
    cin >> s[dex];
    add_element(dex);
    cout << solve() << '\n';
  }
  return 0;
}
