#include <bits/stdc++.h>
using namespace std;
int tree[3][1 << 19];
int N, idx[128], P[200000];
void add_tree(int b, int n, int v, int bit = 1, int s = 0, int e = N - 1) {
  int m = (s + e) >> 1;
  if (s == e) {
    tree[b][bit] += v;
    return;
  }
  if (n <= m)
    add_tree(b, n, v, 2 * bit, s, m);
  else
    add_tree(b, n, v, 2 * bit + 1, m + 1, e);
  tree[b][bit] = tree[b][2 * bit] + tree[b][2 * bit + 1];
}
int get_sum(int b, int n1, int n2, int bit = 1, int s = 0, int e = N - 1) {
  int m = (s + e) >> 1;
  if (n2 < n1 || n2 < s || e < n1) return 0;
  if (n1 <= s && e <= n2) return tree[b][bit];
  return get_sum(b, n1, n2, 2 * bit, s, m) +
         get_sum(b, n1, n2, 2 * bit + 1, m + 1, e);
}
pair<int, int> left_con(int b1, int b2) {
  int bit = 1, s = 0, e = N - 1, l;
  while (s < e) {
    int m = (s + e) >> 1;
    if (tree[b2][2 * bit]) {
      e = m;
      bit = 2 * bit;
    } else {
      s = m + 1;
      bit = 2 * bit + 1;
    }
  }
  if (tree[b2][bit])
    --e;
  else
    ++s;
  l = e + 1;
  bit = 1, s = 0, e = N - 1;
  while (s < e) {
    int m = (s + e) >> 1;
    if (tree[b1][2 * bit] + tree[b2][2 * bit] == m - s + 1) {
      s = m + 1;
      bit = 2 * bit + 1;
    } else {
      e = m;
      bit = 2 * bit;
    }
  }
  if (tree[b1][bit] + tree[b2][bit])
    ++s;
  else
    --e;
  return {l, s - 1};
}
pair<int, int> right_con(int b1, int b2) {
  int bit = 1, s = 0, e = N - 1, r;
  while (s < e) {
    int m = (s + e) >> 1;
    if (tree[b2][2 * bit + 1]) {
      s = m + 1;
      bit = 2 * bit + 1;
    } else {
      e = m;
      bit = 2 * bit;
    }
  }
  if (s == e) {
    if (tree[b2][bit])
      ++s;
    else
      --e;
  }
  r = e;
  bit = 1, s = 0, e = N - 1;
  while (s < e) {
    int m = (s + e) >> 1;
    if (tree[b1][2 * bit + 1] + tree[b2][2 * bit + 1] == e - m) {
      e = m;
      bit = 2 * bit;
    } else {
      s = m + 1;
      bit = 2 * bit + 1;
    }
  }
  if (tree[b1][bit] + tree[b2][bit])
    --e;
  else
    ++s;
  return {s, r};
}
int solve() {
  int ret = 0;
  for (int b1 = 0; b1 < 3; b1++) {
    int b2 = (b1 + 1) % 3;
    auto l = left_con(b1, b2);
    auto r = right_con(b1, b2);
    ret += get_sum(b1, l.first, l.second) + get_sum(b1, r.first, r.second) -
           get_sum(b1, max(l.first, r.first), min(l.second, r.second));
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ((void)0);
  ((void)0);
  ((void)0);
  int Q;
  idx['R'] = 0;
  idx['P'] = 1;
  idx['S'] = 2;
  cin >> N >> Q;
  for (int i = 0; i < N; i++) {
    char c;
    cin >> c;
    P[i] = idx[c];
    add_tree(P[i], i, 1);
  }
  cout << N - solve() << '\n';
  for (; Q; Q--) {
    int a;
    char c;
    cin >> a >> c;
    --a;
    add_tree(P[a], a, -1);
    P[a] = idx[c];
    add_tree(P[a], a, 1);
    cout << N - solve() << '\n';
  }
  return 0;
}
