#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
struct segtree {
  int uv, up;
  int ql, qr, qv;
  int n;
  vector<int> sum;
  void init(int _n) {
    n = _n;
    sum.assign(4 * n + 10, 0);
  }
  void update(int o, int l, int r) {
    if (l == r) {
      sum[o] += uv;
    } else {
      int m = (l + r) / 2;
      if (up <= m) update(o * 2, l, m);
      if (up > m) update(o * 2 + 1, m + 1, r);
      sum[o] = sum[o * 2] + sum[o * 2 + 1];
    }
  }
  void query(int o, int l, int r) {
    if (ql <= l && qr >= r) {
      qv += sum[o];
    } else {
      int m = (l + r) / 2;
      if (ql <= m) query(o * 2, l, m);
      if (qr > m) query(o * 2 + 1, m + 1, r);
    }
  }
  void update(int x, int y) {
    up = x;
    uv = y;
    update(1, 0, n - 1);
  }
  int query(int l, int r) {
    if (l > r) return 0;
    ql = l;
    qr = r;
    qv = 0;
    query(1, 0, n - 1);
    return qv;
  }
};
int n;
vector<segtree> st;
vector<set<int> > pos;
vector<int> a;
int get_first(int s) {
  if (pos[s].empty()) return -1;
  set<int>::iterator it = pos[s].begin();
  return *it;
}
int get_last(int s) {
  if (pos[s].empty()) return -1;
  set<int>::iterator it = pos[s].end();
  it--;
  return *it;
}
int get() {
  int sum = 0;
  for (int it = 0; it < 3; it++) {
    int itt = (it + 1) % 3;
    int ittt = (it + 2) % 3;
    if (pos[itt].empty()) continue;
    if (pos[ittt].empty()) {
      sum += st[it].query(0, n - 1);
      continue;
    }
    int ql = get_first(itt);
    int qr = get_first(ittt);
    sum += st[it].query(ql, qr);
    ql = get_last(ittt);
    qr = get_last(itt);
    sum += st[it].query(ql, qr);
  }
  return n - sum;
}
map<char, int> comp;
void change(int x, int y) {
  st[a[x]].update(x, -1);
  pos[a[x]].erase(x);
  a[x] = y;
  st[a[x]].update(x, 1);
  pos[a[x]].insert(x);
}
int main() {
  comp['R'] = 0;
  comp['P'] = 1;
  comp['S'] = 2;
  int q;
  cin >> n >> q;
  string s;
  cin >> s;
  a.assign(n, 0);
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == 'R') a[i] = 0;
    if (s[i] == 'P') a[i] = 1;
    if (s[i] == 'S') a[i] = 2;
  }
  pos.assign(3, set<int>());
  st.assign(3, segtree());
  for (int i = 0; i < 3; i++) st[i].init(n);
  for (int i = 0; i < n; i++) {
    st[a[i]].update(i, 1);
    pos[a[i]].insert(i);
  }
  printf("%d\n", get());
  while (q--) {
    char c;
    int x;
    cin >> x >> c;
    x--;
    change(x, comp[c]);
    printf("%d\n", get());
  }
  return 0;
}
