#include <bits/stdc++.h>
using namespace std;
string st;
int n;
int BIT[3][1010100];
int id[1010100];
set<int> s[3];
void Up(int k, int u, int v) {
  for (; u <= n; u += u & -u) BIT[k][u] += v;
}
int Get(int k, int u) {
  int ans = 0;
  for (; u > 0; u -= u & -u) ans += BIT[k][u];
  return ans;
}
void Erase(int id, int p) {
  s[id].erase(p);
  Up(id, p + 1, -1);
}
void Insert(int id, int p) {
  s[id].insert(p);
  Up(id, p + 1, 1);
}
int Calc() {
  int ans = n;
  for (int i = 0; i < 3; ++i) {
    int win = (i + 1) % 3, lose = (i + 2) % 3;
    if (s[win].empty()) continue;
    if (s[lose].empty())
      ans -= Get(i, n);
    else {
      int l = *s[win].begin(), r = *s[lose].begin();
      if (l < r) ans -= Get(i, r + 1) - Get(i, l + 1);
      l = *s[lose].rbegin(), r = *s[win].rbegin();
      if (l < r) ans -= Get(i, r + 1) - Get(i, l + 1);
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  cin >> n >> q;
  cin >> st;
  id['R'] = 0, id['P'] = 1, id['S'] = 2;
  for (int p = 0; p < n; ++p) Insert(id[st[p]], p);
  cout << Calc() << '\n';
  while (q--) {
    int p;
    char c;
    cin >> p >> c;
    p--;
    Erase(id[st[p]], p);
    st[p] = c;
    Insert(id[st[p]], p);
    cout << Calc() << '\n';
  }
}
