#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
template <typename T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, 1) : 0;
}
template <typename T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, 1) : 0;
}
inline void solve(), read();
const string file = "";
signed main() {
  if (file != "") {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  read();
  solve();
  return 0;
}
struct fenwick {
  long long n;
  vector<long long> t;
  fenwick() {}
  fenwick(long long n_) {
    n = n_;
    t.resize(n);
  }
  inline long long f(long long i) { return i & (i + 1); }
  inline long long h(long long i) { return i | (i + 1); }
  void inc(long long v, long long x) {
    for (long long i = v; i < n; i = h(i)) {
      t[i] += x;
    }
  }
  long long sum(long long v) {
    long long ans = 0;
    for (long long i = v; i >= 0; i = f(i) - 1) {
      ans += t[i];
    }
    return ans;
  }
  long long sum(long long l, long long r) {
    if (l > r) {
      swap(l, r);
    }
    return sum(r) - sum(l - 1);
  }
};
long long n, q;
fenwick fr, fp, fs;
set<long long> qr, qp, qs;
string s;
long long getr_l() {
  long long n = (long long)((qr).size());
  long long i = *qp.begin();
  long long j = *qs.begin();
  long long ans = 0;
  if (i <= j) {
    ans = fr.sum(i, j);
  }
  return ans;
}
long long getr_r() {
  long long n = (long long)((qr).size());
  long long i = *qp.rbegin();
  long long j = *qs.rbegin();
  long long ans = 0;
  if (i >= j) {
    ans = fr.sum(i, j);
  }
  return ans;
}
long long gets_l() {
  long long n = (long long)((qs).size());
  long long i = *qr.begin();
  long long j = *qp.begin();
  long long ans = 0;
  if (i <= j) {
    ans = fs.sum(i, j);
  }
  return ans;
}
long long gets_r() {
  long long n = (long long)((qs).size());
  long long i = *qr.rbegin();
  long long j = *qp.rbegin();
  long long ans = 0;
  if (i >= j) {
    ans = fs.sum(i, j);
  }
  return ans;
}
long long getp_l() {
  long long n = (long long)((qs).size());
  long long i = *qs.begin();
  long long j = *qr.begin();
  long long ans = 0;
  if (i <= j) {
    ans = fp.sum(i, j);
  }
  return ans;
}
long long getp_r() {
  long long n = (long long)((qs).size());
  long long i = *qs.rbegin();
  long long j = *qr.rbegin();
  long long ans = 0;
  if (i >= j) {
    ans = fp.sum(i, j);
  }
  return ans;
}
long long get1() {
  if (qr.empty() && qs.empty()) {
    return (long long)((qp).size());
  }
  if (qs.empty() && qp.empty()) {
    return (long long)((qr).size());
  }
  if (qr.empty() && qp.empty()) {
    return (long long)((qs).size());
  }
  return -1;
}
long long get2() {
  if (qr.empty()) {
    return (long long)((qs).size());
  }
  if (qs.empty()) {
    return (long long)((qp).size());
  }
  if (qp.empty()) {
    return (long long)((qr).size());
  }
  return -1;
}
long long get() {
  if (get1() != -1) {
    return get1();
  }
  if (get2() != -1) {
    return get2();
  }
  long long ar = getr_l() + getr_r();
  long long ap = getp_l() + getp_r();
  long long as = gets_l() + gets_r();
  return n - (ar + ap + as);
}
void upd(long long i, char c) {
  if (c == 'R') {
    if (s[i] == 'P') {
      fp.inc(i, -1);
      fr.inc(i, +1);
      qp.erase(i);
      qr.insert(i);
    } else if (s[i] == 'S') {
      fs.inc(i, -1);
      fr.inc(i, +1);
      qs.erase(i);
      qr.insert(i);
    }
  } else if (c == 'P') {
    if (s[i] == 'R') {
      fr.inc(i, -1);
      fp.inc(i, +1);
      qr.erase(i);
      qp.insert(i);
    } else if (s[i] == 'S') {
      fs.inc(i, -1);
      fp.inc(i, +1);
      qs.erase(i);
      qp.insert(i);
    }
  } else if (c == 'S') {
    if (s[i] == 'P') {
      fp.inc(i, -1);
      fs.inc(i, +1);
      qp.erase(i);
      qs.insert(i);
    } else if (s[i] == 'R') {
      fr.inc(i, -1);
      fs.inc(i, +1);
      qr.erase(i);
      qs.insert(i);
    }
  }
  s[i] = c;
}
inline void solve() {
  cout << get() << "\n";
  for (long long i = 0; i < q; i++) {
    long long p;
    char c;
    cin >> p >> c;
    --p;
    upd(p, c);
    long long ans = get();
    cout << ans << "\n";
  }
}
inline void read() {
  cin >> n >> q;
  fr = fenwick(n);
  fp = fenwick(n);
  fs = fenwick(n);
  for (long long i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'R') {
      qr.insert(i);
      fr.inc(i, 1);
    } else if (c == 'S') {
      qs.insert(i);
      fs.inc(i, 1);
    } else if (c == 'P') {
      qp.insert(i);
      fp.inc(i, 1);
    }
    s += c;
  }
}
