#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
int const N = 2e5 + 20;
int n, q;
int mp[256], ch[] = {'R', 'P', 'S'};
string s;
int seg[3][N << 2];
set<int> st[3];
void modify(int c, int p, int val, int v = 1, int s = 0, int e = n) {
  if (e - s == 1) {
    seg[c][v] += val;
    return;
  }
  if (p < (s + e) >> 1)
    modify(c, p, val, (v << 1), s, (s + e) >> 1);
  else
    modify(c, p, val, ((v << 1) ^ 1), (s + e) >> 1, e);
  seg[c][v] = seg[c][(v << 1)] + seg[c][((v << 1) ^ 1)];
}
int get(int c, int l, int r, int v = 1, int s = 0, int e = n) {
  if (r <= s || e <= l) return 0;
  if (l <= s && e <= r) return seg[c][v];
  return get(c, l, r, (v << 1), s, (s + e) >> 1) +
         get(c, l, r, ((v << 1) ^ 1), (s + e) >> 1, e);
}
inline int get() {
  int ans = n;
  for (int i = 0; i < 3; i++) {
    int a = i, b = (i + 1) % 3, c = (i + 2) % 3;
    if (!st[a].size()) continue;
    if (!st[b].size()) {
      ans -= st[c].size();
      continue;
    }
    int v1 = *st[a].begin(), v2 = *st[b].begin();
    if (v1 < v2) ans -= get(c, v1, v2);
    v1 = *st[b].rbegin(), v2 = *st[a].rbegin();
    if (v1 < v2) ans -= get(c, v1, v2);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  mp['R'] = 0, mp['P'] = 1, mp['S'] = 2;
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < n; i++) {
    int c = mp[s[i]];
    st[c].insert(i);
    modify(c, i, 1);
  }
  cout << get() << '\n';
  while (q--) {
    int p, c;
    char ch;
    cin >> p >> ch;
    p--;
    c = mp[s[p]];
    modify(c, p, -1);
    st[c].erase(p);
    c = mp[ch];
    s[p] = ch;
    st[c].insert(p);
    modify(c, p, 1);
    cout << get() << '\n';
  }
}
