#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 200200;
char s[maxn];
int len, m;
int a[maxn], L[4], R[4];
set<int> S[3];
inline int W(char c) {
  if (c == 'P')
    return 1;
  else if (c == 'R')
    return 2;
  else
    return 0;
}
struct BIT {
  int a[maxn];
  void add(int p, int x) {
    while (p <= len) {
      a[p] += x;
      p += p & -p;
    }
  }
  int ask(int p) {
    int ret = 0;
    while (p) {
      ret += a[p];
      p -= p & -p;
    }
    return ret;
  }
  int ask(int l, int r) {
    if (l > r) return 0;
    if (l == 0) return ask(r);
    return ask(r) - ask(l - 1);
  }
} t[3];
inline void add(int p, int c, int x) {
  t[c].add(p, x);
  if (x == -1) {
    S[c].erase(p);
    if (!S[c].empty())
      L[c] = *S[c].begin(), R[c] = *S[c].rbegin();
    else
      L[c] = len + 1, R[c] = 0;
  } else {
    S[c].insert(p);
    L[c] = *S[c].begin(), R[c] = *S[c].rbegin();
  }
}
int count(int c) {
  int nxt = (c + 1) % 3, pre = (c + 2) % 3;
  if (L[pre] == len + 1) return 0;
  if (L[nxt] == len + 1) return t[c].ask(1, len);
  int ret = t[c].ask(L[pre], L[nxt]);
  ret += t[c].ask(R[nxt], R[pre]);
  return ret;
}
void out() { printf("%d\n", len - count(0) - count(1) - count(2)); }
void work() {
  len = read(), m = read();
  scanf("%s", s + 1);
  L[0] = L[1] = L[2] = len + 1;
  for (register int i = (int)(1); i <= (int)(len); i++) {
    a[i] = W(s[i]);
    add(i, a[i], 1);
  }
  out();
  for (register int i = (int)(1); i <= (int)(m); i++) {
    int p = read();
    char c = getchar();
    while (!(c >= 'A' && c <= 'Z')) c = getchar();
    add(p, a[p], -1);
    a[p] = W(c);
    add(p, a[p], 1);
    out();
  }
}
int main() { work(); }
