#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void amax(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class X, class Y>
void amin(X &x, const Y &y) {
  if (x > y) x = y;
}
const int INF = 1e9 + 10;
const long long INFL = (long long)1e18 + 10;
const int MAX = 2e5 + 10;
int n, q;
string s;
int a[MAX];
int cnt[3][MAX];
set<int> pos[3];
int res;
int getid(char c) {
  if (c == 'R')
    return 0;
  else if (c == 'S')
    return 1;
  return 2;
}
void update(int i, int p, int v) {
  for (; p <= n; p += p & -p) cnt[i][p] += v;
}
int query(int i, int p) {
  int res = 0;
  for (; p >= 1; p -= p & -p) res += cnt[i][p];
  return res;
}
int query(int i, int l, int r) {
  amin(r, n);
  if (l > r) return 0;
  return query(i, r) - query(i, l - 1);
}
int c1(int x) { return (x + 1) % 3; }
int c2(int x) { return (x + 2) % 3; }
bool check(int i) {
  bool le = query(c1(a[i]), i - 1) > 0 || query(c2(a[i]), i - 1) == 0;
  bool ri = query(c1(a[i]), i + 1, n) > 0 || query(c2(a[i]), i + 1, n) == 0;
  return le && ri;
}
void init() {
  for (int i = 0; i < n; i++) {
    a[i + 1] = getid(s[i]);
  }
  for (int i = 1; i <= n; i++) {
    update(a[i], i, 1);
    pos[a[i]].insert(i);
  }
  for (int i = 1; i <= n; i++) res += check(i);
}
int next_right(int i, int c) {
  auto it = pos[c].lower_bound(i);
  if (it == pos[c].end()) return n + 1;
  return *it;
}
int next_left(int i, int c) {
  if (pos[c].empty()) return 0;
  auto it = pos[c].upper_bound(i);
  if (it == pos[c].begin()) return 0;
  return *prev(it);
}
int calc_left_c2(int i) {
  int p = next_left(i, c2(a[i]));
  if (query(c1(a[i]), p, n) == 0) p = next_left(p, c1(a[i]));
  if (p == 0 || query(a[i], p, n) > 0) return 0;
  int p1 = next_left(p, a[i]);
  if (p1 == 0) amin(p, next_right(1, c1(a[i])));
  return query(c2(a[i]), p1, p);
}
int calc_right_c2(int i) {
  int p = next_right(i, c2(a[i]));
  if (query(c1(a[i]), 1, p) == 0) p = next_right(p, c1(a[i]));
  if (p == n + 1 || query(a[i], 1, p) > 0) return 0;
  int p1 = next_right(p, a[i]);
  if (p1 == n + 1) amax(p, next_left(n, c1(a[i])));
  return query(c2(a[i]), p, p1);
}
int calc_left_c1(int i) {
  int p = next_left(i, c1(a[i]));
  if (p == 0 || query(c2(a[i]), p, n) > 0 || query(a[i], p, n) > 0) return 0;
  int p1 = next_left(p, c2(a[i]));
  if (p1 == 0 && query(a[i], 1, p) > 0) return 0;
  amax(p1, next_left(p, a[i]));
  return query(c1(a[i]), p1, p);
}
int calc_right_c1(int i) {
  int p = next_right(i, c1(a[i]));
  if (p == n + 1 || query(c2(a[i]), 1, p) > 0 || query(a[i], 1, p) > 0)
    return 0;
  int p1 = next_right(p, c2(a[i]));
  if (p1 == n + 1 && query(a[i], p, n) > 0) return 0;
  amin(p1, next_right(p, a[i]));
  return query(c1(a[i]), p, p1);
}
void request(int i, int c) {
  if (a[i] == c) return;
  res -= check(i);
  update(a[i], i, -1);
  pos[a[i]].erase(i);
  res -= calc_right_c2(i);
  res -= calc_left_c2(i);
  res += calc_right_c1(i);
  res += calc_left_c1(i);
  a[i] = c;
  res += calc_right_c2(i);
  res += calc_left_c2(i);
  res -= calc_right_c1(i);
  res -= calc_left_c1(i);
  update(a[i], i, 1);
  pos[a[i]].insert(i);
  res += check(i);
}
void process() {
  cin >> n >> q >> s;
  init();
  cout << res << '\n';
  while (q--) {
    int i;
    char c;
    cin >> i >> c;
    request(i, getid(c));
    cout << res << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  process();
}
