#include <bits/stdc++.h>
using namespace std;
struct rec {
  int l, r;
};
int i, j, m, n, q, num[200005], x;
char s[200005], ch;
rec tree[800005];
int cnt[800005][3][4][4], ans;
bool have[800005][3];
void pushup(int rt) {
  int i, j, k;
  memset(cnt[rt], 0, sizeof(cnt[rt]));
  for (i = 0; i <= 2; i++) {
    int right = 0;
    int left = 0;
    if (have[rt << 1 | 1][(i + 1) % 3]) {
      right += 2;
    }
    if (have[rt << 1 | 1][(i + 2) % 3]) {
      right++;
    }
    for (j = 0; j <= 3; j++) {
      for (k = 0; k <= 3; k++) {
        cnt[rt][i][j][k | right] += cnt[rt << 1][i][j][k];
      }
    }
    if (have[rt << 1][(i + 1) % 3]) {
      left += 2;
    }
    if (have[rt << 1][(i + 2) % 3]) {
      left++;
    }
    for (j = 0; j <= 3; j++) {
      for (k = 0; k <= 3; k++) {
        cnt[rt][i][j | left][k] += cnt[rt << 1 | 1][i][j][k];
      }
    }
  }
  for (i = 0; i <= 2; i++) {
    have[rt][i] = have[rt << 1][i] || have[rt << 1 | 1][i];
  }
}
void build(int rt, int l, int r) {
  tree[rt].l = l;
  tree[rt].r = r;
  if (l == r) {
    cnt[rt][num[l]][0][0] = 1;
    have[rt][num[l]] = true;
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  pushup(rt);
}
void update(int rt, int l, int c) {
  if (tree[rt].l == tree[rt].r) {
    int i;
    for (i = 0; i <= 2; i++) {
      cnt[rt][i][0][0] = 0;
      have[rt][i] = false;
    }
    cnt[rt][c][0][0] = 1;
    have[rt][c] = true;
    return;
  }
  int mid = (tree[rt].l + tree[rt].r) >> 1;
  if (l <= mid) {
    update(rt << 1, l, c);
  } else {
    update(rt << 1 | 1, l, c);
  }
  pushup(rt);
}
int getans() {
  int i, j, k;
  int ret = 0;
  for (i = 0; i <= 2; i++) {
    for (j = 0; j <= 3; j++) {
      if (j != 2) {
        for (k = 0; k <= 3; k++) {
          if (k != 2) {
            ret += cnt[1][i][j][k];
          }
        }
      }
    }
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (i = 1; i <= n; i++) {
    if (s[i - 1] == 'R') {
      num[i] = 0;
    } else if (s[i - 1] == 'P') {
      num[i] = 1;
    } else {
      num[i] = 2;
    }
  }
  build(1, 1, n);
  ans = getans();
  printf("%d\n", ans);
  while (q--) {
    scanf("%d%c%c", &x, &ch, &ch);
    if (ch == 'R') {
      update(1, x, 0);
    } else if (ch == 'P') {
      update(1, x, 1);
    } else {
      update(1, x, 2);
    }
    ans = getans();
    printf("%d\n", ans);
  }
  return 0;
}
