#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const long long INFF = (long long)1e15;
const int mod = 998244353;
const int MXN = (int)2e5 + 7;
char s[MXN];
int n, q;
int sub(char ch) {
  if (ch == 'P')
    return 0;
  else if (ch == 'S')
    return 1;
  else
    return 2;
}
struct Bit {
  int a[MXN];
  void md(int i, int v) {
    for (; i < MXN; i += i & (-i)) a[i] += v;
  }
  int qy2(int p) {
    int res = 0;
    for (int i = p; i > 0; i -= i & (-i)) res += a[i];
    return res;
  }
  int qy(int l, int r) {
    if (l > r) return 0;
    return qy2(r) - qy2(l - 1);
  }
} bit[3];
set<int> st[3];
int val(pair<int, int> v1, pair<int, int> v2, int i) {
  int res = 0;
  res += bit[i].qy(v1.first, v1.second);
  res += bit[i].qy(v2.first, v2.second);
  res -= bit[i].qy(max(v1.first, v2.first), min(v1.second, v2.second));
  return res;
}
void sol() {
  int ans = n;
  for (int i = 0; i < 3; i++) {
    int p1 = (i + 1) % 3;
    int p2 = (i + 2) % 3;
    if (st[p1].empty()) continue;
    if (st[p2].empty()) {
      ans -= (int)(st[i]).size();
      continue;
    }
    pair<int, int> seg1 = make_pair(*st[p1].begin(), *st[p2].begin());
    pair<int, int> seg2 = make_pair(*(--st[p2].end()), *(--st[p1].end()));
    ans -= val(seg1, seg2, i);
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%d %d %s", &n, &q, s + 1);
  for (int i = 1; i <= n; i++) {
    int v = sub(s[i]);
    st[v].insert(i);
    bit[v].md(i, 1);
  }
  sol();
  while (q--) {
    int p;
    char typ[3];
    scanf("%d %s", &p, typ);
    int u = sub(s[p]);
    int v = sub(typ[0]);
    st[u].erase(p);
    bit[u].md(p, -1);
    st[v].insert(p);
    bit[v].md(p, 1);
    s[p] = typ[0];
    sol();
  }
  return 0;
}
