#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using f64 = double;
using f80 = long double;
using pii = pair<int, int>;
using pll = pair<i64, i64>;
using ptx = pair<f64, f64>;
const int N = 3e5 + 5;
char str[N];
int r[N], p[N], s[N];
set<int> rs, ps, ss;
int n, q;
static inline int lsb(const int &arg) { return arg & -arg; }
static void update(int aib[], int pos, int val) {
  for (; pos < N; pos += lsb(pos)) aib[pos] += val;
}
static int query(int aib[], int pos) {
  int ant = 0;
  for (; pos > 0; pos -= lsb(pos)) ant += aib[pos];
  return ant;
}
static int prefix() {
  int ant, sum, *aib;
  switch (str[1]) {
    case 'R': {
      aib = r;
      break;
    }
    case 'P': {
      aib = p;
      break;
    }
    case 'S': {
      aib = s;
      break;
    }
  }
  ant = sum = 0;
  for (int msk = 1 << 20; msk > 0; msk /= 2)
    if (ant + msk <= n && sum + aib[ant + msk] == ant + msk) {
      ant += msk;
      sum += msk;
    }
  return ant;
}
static int suffix() {
  int ant, sum, total, *aib;
  switch (str[n]) {
    case 'R': {
      aib = r;
      total = rs.size();
      break;
    }
    case 'P': {
      aib = p;
      total = ps.size();
      break;
    }
    case 'S': {
      aib = s;
      total = ss.size();
      break;
    }
  }
  ant = sum = 0;
  for (int msk = 1 << 20; msk > 0; msk /= 2)
    if (ant + msk <= n && total - (sum + aib[ant + msk]) != n - ant - msk) {
      ant += msk;
      sum += aib[ant];
    }
  ant += 1;
  while (str[ant] != str[n]) ++ant;
  return ant;
}
static void initialize() {
  for (int i = 1; i <= n; ++i) {
    switch (str[i]) {
      case 'R': {
        update(r, i, 1);
        rs.insert(i);
        break;
      }
      case 'P': {
        update(p, i, 1);
        ps.insert(i);
        break;
      }
      case 'S': {
        update(s, i, 1);
        ss.insert(i);
        break;
      }
    }
  }
}
static int query() {
  vector<pii> ivs;
  int rt, lf, ant = 0;
  if (rs.size() > 1) {
    lf = *rs.begin();
    rt = *rs.rbegin();
    ant += query(p, rt) - query(p, lf - 1);
  }
  if (ps.size() > 1) {
    lf = *ps.begin();
    rt = *ps.rbegin();
    ant += query(s, rt) - query(s, lf - 1);
  }
  if (ss.size() > 1) {
    lf = *ss.begin();
    rt = *ss.rbegin();
    ant += query(r, rt) - query(r, lf - 1);
  }
  lf = prefix();
  if (lf == n) return n;
  switch (str[1]) {
    case 'R': {
      if (!ss.empty()) ant += lf;
      break;
    }
    case 'P': {
      if (!rs.empty()) ant += lf;
      break;
    }
    case 'S': {
      if (!ps.empty()) ant += lf;
      break;
    }
  }
  rt = suffix();
  switch (str[n]) {
    case 'R': {
      if (!ss.empty()) ant += n - rt + 1;
      break;
    }
    case 'P': {
      if (!rs.empty()) ant += n - rt + 1;
      break;
    }
    case 'S': {
      if (!ps.empty()) ant += n - rt + 1;
      break;
    }
  }
  return ant;
}
static void update(int pos, char op) {
  int *aib;
  switch (str[pos]) {
    case 'R': {
      rs.erase(pos);
      aib = r;
      break;
    }
    case 'P': {
      ps.erase(pos);
      aib = p;
      break;
    }
    case 'S': {
      ss.erase(pos);
      aib = s;
      break;
    }
  }
  update(aib, pos, -1);
  str[pos] = op;
  switch (str[pos]) {
    case 'R': {
      rs.insert(pos);
      aib = r;
      break;
    }
    case 'P': {
      ps.insert(pos);
      aib = p;
      break;
    }
    case 'S': {
      ss.insert(pos);
      aib = s;
      break;
    }
  }
  update(aib, pos, 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int pos;
  char op;
  cin >> n >> q;
  cin >> (str + 1);
  initialize();
  cout << query() << '\n';
  while (q--) {
    cin >> pos >> op;
    update(pos, op);
    cout << query() << '\n';
  }
  return 0;
}
