#include <bits/stdc++.h>
using namespace std;
const int maxn = 200050;
int sum[3][maxn + 10], po, q, aim[maxn];
set<int> pos[3];
set<int>::iterator it;
int n, aga[3][2] = {{2, 1}, {0, 2}, {1, 0}};
char s[maxn], tmp[5];
int lowbit(int x) { return x & (-x); }
int query(int x, int sum[]) {
  int ans = 0;
  while (x) {
    ans += sum[x];
    x -= lowbit(x);
  }
  return ans;
}
void add(int x, int num, int sum[]) {
  while (x < maxn) {
    sum[x] += num;
    x += lowbit(x);
  }
}
int Cal(int now) {
  if (pos[now].size() == 0) return 0;
  int ruo = aga[now][0], qiang = aga[now][1], aans = 0;
  if (pos[ruo].size() == 0) {
    if (pos[qiang].size() != 0)
      return 0;
    else
      return pos[now].size();
  } else {
    if (pos[qiang].size() == 0) return pos[now].size();
    int l = *pos[ruo].begin(), r = *pos[ruo].rbegin();
    aans += (query(r, sum[now]) - query(l, sum[now]));
    int st = *pos[qiang].begin(), en = *pos[qiang].rbegin();
    int qian = min(st, l), hou = max(r, en);
    aans +=
        query(qian, sum[now]) + query(maxn, sum[now]) - query(hou, sum[now]);
  }
  return aans;
}
int gain(char a) {
  if (a == 'S')
    return 0;
  else if (a == 'R')
    return 1;
  else
    return 2;
}
void vispos(int x) {
  if (pos[x].size() == 0)
    cout << "0" << endl;
  else {
    for (it = pos[x].begin(); it != pos[x].end(); it++) {
      printf("%d ", *it);
    }
    cout << endl;
  }
}
int main() {
  scanf("%d%d%s", &n, &q, s + 1);
  for (int i = 1; i <= n; i++) {
    aim[i] = gain(s[i]);
    add(i, 1, sum[aim[i]]);
    pos[aim[i]].insert(i);
  }
  printf("%d\n", Cal(0) + Cal(1) + Cal(2));
  for (int i = 1; i <= q; i++) {
    scanf("%d%s", &po, tmp + 1);
    int obj = gain(tmp[1]), yuan = aim[po];
    add(po, -1, sum[yuan]);
    pos[yuan].erase(po);
    add(po, 1, sum[obj]);
    pos[obj].insert(po);
    printf("%d\n", Cal(0) + Cal(1) + Cal(2));
    aim[po] = obj;
  }
  return 0;
}
