#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void ckmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void ckmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int maxn = (1 << 20);
int n, nq;
int a[maxn];
set<int> p[3];
int s[3][maxn];
bool win_prefix(int length, int key) {
  int w = (key + 1) % 3;
  if (!p[w].empty() && *p[w].begin() < length) return true;
  int l = (key + 2) % 3;
  if (!p[l].empty() && *p[l].begin() < length) return false;
  return true;
}
bool win_suffix(int length, int key) {
  int w = (key + 1) % 3;
  if (!p[w].empty() && *p[w].rbegin() >= n - length) return true;
  int l = (key + 2) % 3;
  if (!p[l].empty() && *p[l].rbegin() >= n - length) return false;
  return true;
}
bool win(int at, int key) {
  return win_prefix(at, key) && win_suffix(n - 1 - at, key);
}
int calc(int s[], int p);
int solve(int key) {
  int w = (key + 1) % 3;
  int l = (key + 2) % 3;
  set<int> pos;
  if (!p[w].empty()) {
    pos.insert(*p[w].begin());
    pos.insert(*p[w].rbegin());
  }
  if (!p[l].empty()) {
    pos.insert(*p[l].begin());
    pos.insert(*p[l].rbegin());
  }
  set<int> extended_pos;
  extended_pos.insert(0);
  extended_pos.insert(n);
  for (int p : pos)
    for (int d = -2; d <= 2; d++)
      if (p + d >= 0 && p + d <= n) extended_pos.insert(p + d);
  vector<int> wpos(extended_pos.begin(), extended_pos.end());
  int ret = 0, last_s = -1, last_t = -1;
  for (int i = 0; i < (((int)wpos.size()) - 1); ++i)
    if (win(wpos[i], key))
      if (last_t == wpos[i])
        last_t = wpos[i + 1];
      else {
        if (last_s >= 0) ret += calc(s[key], last_t) - calc(s[key], last_s);
        last_s = wpos[i];
        last_t = wpos[i + 1];
      }
  if (last_s >= 0) ret += calc(s[key], last_t) - calc(s[key], last_s);
  return ret;
}
int solve() {
  int ret = 0;
  for (int k = 0; k < (3); ++k) ret += solve(k);
  return ret;
}
void update(int s[], int p, int d) {
  for (; p <= n; p = (p | (p - 1)) + 1) s[p] += d;
}
int calc(int s[], int p) {
  int r = 0;
  for (; p; p &= (p - 1)) r += s[p];
  return r;
}
int main() {
  std::ios::sync_with_stdio(false);
  while (cin >> n >> nq) {
    string s0;
    cin >> s0;
    for (int i = 0; i < (n); ++i)
      a[i] = (s0[i] == 'R' ? 2 : (s0[i] == 'P' ? 1 : 0));
    for (int k = 0; k < (3); ++k) p[k].clear();
    for (int i = 0; i < (n); ++i) p[a[i]].insert(i);
    for (int k = 0; k < (3); ++k) memset(s[k], 0, (n + 1) * sizeof(int));
    for (int i = 0; i < (n); ++i) update(s[a[i]], i + 1, 1);
    int ret = solve();
    printf("%d\n", ret);
    for (int cl = 0; cl < (nq); ++cl) {
      int pos;
      string s0;
      cin >> pos >> s0;
      int key = (s0[0] == 'R' ? 2 : (s0[0] == 'P' ? 1 : 0));
      --pos;
      p[a[pos]].erase(pos);
      update(s[a[pos]], pos + 1, -1);
      a[pos] = key;
      p[a[pos]].insert(pos);
      update(s[a[pos]], pos + 1, 1);
      int ret = solve();
      printf("%d\n", ret);
    }
    break;
  }
  return 0;
}
