#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 233333;
int n, q, a[N];
set<int> Set[3];
int v[3][N];
int getid(char c) {
  if (c == 'P') return 2;
  if (c == 'R') return 1;
  if (c == 'S') return 0;
}
void add(int *v, int p, int x) {
  while (p <= n) v[p] += x, p += p & -p;
}
int query(int *v, int p) {
  int r = 0;
  while (p) r += v[p], p -= p & -p;
  return r;
}
int query(int i, int l, int r) {
  if (l > r) return 0;
  return query(v[i], r) - query(v[i], l - 1);
}
void ins(int x, int y, int tp) {
  if (tp < 0)
    Set[y].erase(x);
  else
    Set[y].insert(x);
  add(v[y], x, tp);
}
int query() {
  int S = 0;
  for (register int i = 0; i <= 2; i++)
    if (((int)Set[i].size())) S |= 1 << i;
  int res = 0;
  if (S == 7) {
    res = n;
    for (register int i = 0; i <= 2; i++) {
      int a = (i + 1) % 3, b = (i - 1 + 3) % 3;
      res -= query(i, *Set[a].begin(), *Set[b].begin()) +
             query(i, *Set[b].rbegin(), *Set[a].rbegin());
    }
  } else if (S == 3) {
    res = n - ((int)Set[0].size());
  } else if (S == 5) {
    res = n - ((int)Set[2].size());
  } else if (S == 6) {
    res = n - ((int)Set[1].size());
  } else
    res = n;
  return res;
}
int main() {
  read(n);
  read(q);
  static char t[N];
  scanf("%s", t + 1);
  for (register int i = 1; i <= n; i++) a[i] = getid(t[i]);
  for (register int i = 1; i <= n; i++) ins(i, a[i], 1);
  printf("%d\n", query());
  while (q--) {
    int x;
    read(x);
    scanf("%s", t);
    int y = getid(t[0]);
    ins(x, a[x], -1);
    a[x] = y;
    ins(x, y, 1);
    printf("%d\n", query());
  }
  return 0;
}
