#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
template <class T, int sz>
struct BIT {
  T b[sz + 1];
  BIT() {
    for (int i = 0; i < sz + 1; i++) b[i] = 0;
  }
  void add(int k, T val) {
    k++;
    for (; k <= sz; k += (k & -k)) b[k] += val;
  }
  T psum(int ind) {
    T ans = 0;
    ind++;
    for (; ind > 0; ind -= (ind & -ind)) ans += b[ind];
    return ans;
  }
  T sum(int l, int r) { return psum(r) - psum(l - 1); }
};
int toInt(char c) {
  if (c == 'R')
    return 0;
  else if (c == 'P')
    return 1;
  return 2;
}
const int MAX_N = 200005;
int n, q;
BIT<int, MAX_N> bits[3];
set<int> b[3];
int getFirst(int x) {
  if (!b[x].empty()) return *b[x].begin();
  return n;
}
int getLast(int x) {
  if (!b[x].empty()) return *b[x].rbegin();
  return -1;
}
int getCnt(int x, vector<pair<int, int> >& v) {
  int res = bits[x].psum(n - 1);
  if ((int)v.size() == 0)
    return res;
  else if ((int)v.size() == 1) {
    return res - bits[x].sum(v[0].first, v[0].second);
  } else {
    pair<int, int> p1 = v[0];
    pair<int, int> p2 = v[1];
    if (p1.second >= p2.first) {
      return res - bits[x].sum(p1.first, p2.second);
    } else {
      return res - bits[x].sum(p1.first, p1.second) -
             bits[x].sum(p2.first, p2.second);
    }
  }
}
int getAns() {
  int ans = 0;
  for (int x = 0; x < 3; x++) {
    int bad = (x + 1) % 3;
    int good = (x + 2) % 3;
    pair<int, int> p1 = make_pair(getFirst(bad), getFirst(good) - 1);
    pair<int, int> p2 = make_pair(getLast(good) + 1, getLast(bad));
    vector<pair<int, int> > restrictions;
    if (p1.first <= p1.second) restrictions.push_back(p1);
    if (p2.first <= p2.second) restrictions.push_back(p2);
    sort(restrictions.begin(), restrictions.end());
    ans += getCnt(x, restrictions);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  string second;
  cin >> second;
  for (int i = 0; i < n; i++) {
    int x = toInt(second[i]);
    b[x].insert(i);
    bits[x].add(i, 1);
  }
  cout << getAns() << "\n";
  for (int i = 0; i < q; i++) {
    int idx;
    char c;
    cin >> idx >> c;
    idx--;
    int x = toInt(c);
    int x0 = toInt(second[idx]);
    b[x0].erase(idx);
    bits[x0].add(idx, -1);
    b[x].insert(idx);
    bits[x].add(idx, 1);
    second[idx] = c;
    cout << getAns() << "\n";
  }
}
