#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
template <class T>
inline T _max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline bool checkmax(T &a, T b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
inline bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 200005;
set<int> S[3];
set<int>::iterator it;
int C[3][N], a[N];
int n, q;
char s[N];
int Typ(char x) {
  if (x == 'P')
    return 0;
  else if (x == 'S')
    return 1;
  else if (x == 'R')
    return 2;
}
void update(int idx, int x, int num) {
  if (!x) return;
  for (; x <= n + 1; x += (x & (-x))) {
    C[idx][x] += num;
  }
}
int query(int idx, int x) {
  int ans = 0;
  for (; x; x -= (x & (-x))) {
    ans += C[idx][x];
  }
  return ans;
}
void init() {
  read(n);
  read(q);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = Typ(s[i]);
    update(a[i], i, 1);
    S[a[i]].insert(i);
  }
}
int calc() {
  if ((S[0].empty()) + (S[1].empty()) + (S[2].empty()) == 2) return n;
  if (S[0].empty()) return (int)S[2].size();
  if (S[1].empty()) return (int)S[0].size();
  if (S[2].empty()) return (int)S[1].size();
  int ans = 0;
  for (int i = 0; i <= 2; ++i) {
    int eat = (i + 1) % 3, eaten = (i + 2) % 3;
    int l = *S[eaten].begin(), r = *S[eaten].rbegin();
    int L = *S[eat].begin(), R = *S[eat].rbegin();
    int tmp = (int)S[i].size();
    if (L < l) tmp -= query(i, l) - query(i, L);
    if (r < R) tmp -= query(i, R) - query(i, r);
    ans += tmp;
  }
  return ans;
}
void solve() {
  printf("%d\n", calc());
  for (int i = 1, x; i <= q; ++i) {
    read(x);
    scanf("%s", s);
    S[a[x]].erase(x);
    update(a[x], x, -1);
    a[x] = Typ(s[0]);
    S[a[x]].insert(x);
    update(a[x], x, 1);
    printf("%d\n", calc());
  }
}
int main() {
  init();
  solve();
  return 0;
}
