#include <bits/stdc++.h>
using namespace std;
constexpr int MAX_N = 200200;
int n, m;
char arr[MAX_N];
int tree[3][4 * MAX_N];
int redir[256];
set<int> poses[3];
int beats(int x) { return (x + 2) % 3; }
int loses(int x) { return (x + 1) % 3; }
int update(int which, int i, int l, int r, int j) {
  if (j < l || j > r) return tree[which][i];
  if (l == r) {
    tree[which][i] = arr[j] == which;
  } else {
    tree[which][i] = update(which, 2 * i + 1, l, (l + r) / 2, j) +
                     update(which, 2 * i + 2, (l + r) / 2 + 1, r, j);
  }
  return tree[which][i];
}
void update_all(int j) {
  for (int which = 0; which < 3; ++which) {
    update(which, 0, 1, n, j);
    if (arr[j] == which) {
      poses[which].insert(j);
    } else {
      if (poses[which].find(j) != poses[which].end()) {
        poses[which].erase(poses[which].find(j));
      }
    }
  }
}
int query(int which, int i, int l, int r, int a, int b) {
  if (b < l || a > r) return 0;
  if (l >= a && r <= b) return tree[which][i];
  return query(which, 2 * i + 1, l, (l + r) / 2, a, b) +
         query(which, 2 * i + 2, (l + r) / 2 + 1, r, a, b);
}
int get_first(int which) {
  return poses[which].size() ? *poses[which].begin() : -1;
}
int get_last(int which) {
  return poses[which].size() ? *prev(poses[which].end()) : -1;
}
int solve() {
  int ans = 0;
  for (int which = 0; which < 3; ++which) {
    ans += query(which, 0, 1, n, 1, n);
    int first_lose = get_first(loses(which));
    int first_beat = get_first(beats(which));
    if (first_lose == -1) continue;
    if (first_beat == -1) {
      ans -= query(which, 0, 1, n, 1, n);
      continue;
    }
    if (first_lose < first_beat) {
      ans -= query(which, 0, 1, n, first_lose, first_beat);
    }
    int last_lose = get_last(loses(which));
    int last_beat = get_last(beats(which));
    if (last_beat < last_lose) {
      ans -= query(which, 0, 1, n, last_beat, last_lose);
    }
  }
  return ans;
}
int main() {
  redir['R'] = 0;
  redir['P'] = 1;
  redir['S'] = 2;
  scanf(" %d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    char c;
    scanf(" %c", &c);
    arr[i] = redir[c];
    update_all(i);
  }
  printf("%d\n", solve());
  for (int i = 0; i < m; ++i) {
    int idx;
    char c;
    scanf(" %d %c", &idx, &c);
    arr[idx] = redir[c];
    update_all(idx);
    printf("%d\n", solve());
  }
  return 0;
}
