#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <class T>
int chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
int chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T mmin(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T mmax(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T aabs(T a) {
  return a < 0 ? -a : a;
}
template <class T>
int dcmp(T a, T b) {
  return a > b;
}
template <int *a>
int cmp_a(int first, int second) {
  return a[first] < a[second];
}
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char first) {
  *oS++ = first;
  if (oS == oT) flush();
}
inline void read(int &first) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (first = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    first = first * 10 + (c & 15);
  first *= f;
}
inline void read(char &first) {
  first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                    : *iS++);
}
inline void read(char *first) {
  while ((*first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                                (iS == iT ? EOF : *iS++))
                             : *iS++)) == '\n' ||
         *first == ' ' || *first == '\r')
    ;
  while (!(*first == '\n' || *first == ' ' || *first == '\r'))
    *(++first) = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                           : *iS++);
}
template <typename A, typename... B>
inline void read(A &first, B &...second) {
  read(first);
  read(second...);
}
inline void write(int first) {
  if (!first) putc('0');
  if (first < 0) putc('-'), first = -first;
  while (first) qu[++qr] = first % 10 + '0', first /= 10;
  while (qr) putc(qu[qr--]);
}
inline void write(char first) { putc(first); }
inline void write(const char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
}
inline void write(char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
}
template <typename A, typename... B>
inline void write(A first, B... second) {
  write(first);
  write(second...);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::putc;
using io ::read;
using io ::write;
set<int> R, P, S;
int n, q, p;
char s[200005];
struct BIT {
  int a[200005];
  void add(int first, int second) {
    for (; first <= n; first += first & -first) a[first] += second;
  }
  int sum(int first) {
    int second = 0;
    for (; first; first &= first - 1) second += a[first];
    return second;
  }
};
BIT Rb, Pb, Sb;
void insert(int first) {
  if (s[first] == 'R') {
    R.insert(first);
    Rb.add(first, 1);
  }
  if (s[first] == 'P') {
    P.insert(first);
    Pb.add(first, 1);
  }
  if (s[first] == 'S') {
    S.insert(first);
    Sb.add(first, 1);
  }
}
void remove(int first) {
  if (s[first] == 'R') {
    R.erase(first);
    Rb.add(first, -1);
  }
  if (s[first] == 'P') {
    P.erase(first);
    Pb.add(first, -1);
  }
  if (s[first] == 'S') {
    S.erase(first);
    Sb.add(first, -1);
  }
}
int query() {
  int ans = n;
  if (S.empty())
    ;
  else if (P.empty()) {
    if (!R.empty()) ans -= S.size();
  } else if (!R.empty()) {
    if (*R.begin() < *P.begin()) ans += Sb.sum(*R.begin()) - Sb.sum(*P.begin());
    if (*P.rbegin() < *R.rbegin())
      ans += Sb.sum(*P.rbegin()) - Sb.sum(*R.rbegin());
  }
  if (P.empty())
    ;
  else if (R.empty()) {
    if (!S.empty()) ans -= P.size();
  } else if (!S.empty()) {
    if (*S.begin() < *R.begin())
      ans += (Pb.sum(*S.begin()) - Pb.sum(*R.begin()));
    if (*R.rbegin() < *S.rbegin())
      ans += (Pb.sum(*R.rbegin()) - Pb.sum(*S.rbegin()));
  }
  if (P.empty())
    ;
  if (R.empty())
    ;
  else if (S.empty()) {
    if (!P.empty()) ans -= R.size();
  } else if (!P.empty()) {
    if (*P.begin() < *S.begin())
      ans += (Rb.sum(*P.begin()) - Rb.sum(*S.begin()));
    if (*S.rbegin() < *P.rbegin())
      ans += (Rb.sum(*S.rbegin()) - Rb.sum(*P.rbegin()));
  }
  return ans;
}
int main() {
  char c;
  scanf("%d%d\n%s", &n, &q, s + 1);
  for (int i = 1; i <= n; ++i) {
    insert(i);
  }
  printf("%d\n", query());
  for (; q; --q) {
    scanf("%d %c", &p, &c);
    remove(p);
    s[p] = c;
    insert(p);
    printf("%d\n", query());
  }
  return 0;
}
