#include <bits/stdc++.h>
using namespace std;
template <class V, class U>
struct SegTree {
  int n;
  vector<V> st;
  vector<U> lazy;
  vector<int> leaves;
  vector<int> originalArray;
  SegTree(const int n) : n(n) {
    leaves.resize(n);
    originalArray.resize(n);
    init();
    lazy.resize(st.size());
  }
  void init() { init(1, 0, n - 1); }
  void init(const int si, const int lo, const int hi) {
    if (lo == hi) {
      if (si >= (int)st.size()) st.resize(si + 1);
      st[si] = V(originalArray[lo]);
      leaves[lo] = si;
    } else {
      const int mid = (lo + hi) >> 1;
      init(si << 1, lo, mid);
      init(si << 1 | 1, mid + 1, hi);
      st[si] = V(st[si << 1], st[si << 1 | 1]);
    }
  }
  void updateLazy(const int si, const int lo, const int hi) {
    lazy[si].apply(st[si], lo, hi);
    if (lo != hi) {
      lazy[si << 1] = U(lazy[si << 1], lazy[si]);
      lazy[si << 1 | 1] = U(lazy[si << 1 | 1], lazy[si]);
    }
    lazy[si] = U();
  }
  V query(const int l, const int r) {
    return (l <= r && l < n && r >= 0) ? query(l, r, 1, 0, n - 1) : V();
  }
  V query(const int l, const int r, const int si, const int lo, const int hi) {
    updateLazy(si, lo, hi);
    if (l <= lo && hi <= r) return st[si];
    const int mid = (lo + hi) >> 1;
    if (r <= mid) return query(l, r, si << 1, lo, mid);
    if (mid < l) return query(l, r, si << 1 | 1, mid + 1, hi);
    return V(query(l, r, si << 1, lo, mid),
             query(l, r, si << 1 | 1, mid + 1, hi));
  }
  void update(const int l, const int r, const U u) {
    if (l <= r) update(l, r, u, 1, 0, n - 1);
  }
  void update(const int l, const int r, const U& u, const int si, const int lo,
              const int hi) {
    if (l <= lo && r >= hi) {
      lazy[si] = U(lazy[si], u);
      updateLazy(si, lo, hi);
    } else {
      updateLazy(si, lo, hi);
      if (l > hi || r < lo) return;
      const int mid = (lo + hi) >> 1;
      update(l, r, u, si << 1, lo, mid);
      update(l, r, u, si << 1 | 1, mid + 1, hi);
      st[si] = V(st[si << 1], st[si << 1 | 1]);
    }
  }
  void update(const int i, U u) {
    int si = leaves[i];
    u.apply(st[si]);
    for (si >>= 1; si; si >>= 1) st[si] = V(st[si << 1], st[si << 1 | 1]);
  }
  vector<int> remAll(const int l, const int r) {
    vector<int> res;
    remAll(l, r, 1, 0, n - 1, res);
    return res;
  }
  void remAll(const int l, const int r, const int si, const int lo,
              const int hi, vector<int>& res) {
    updateLazy(si, lo, hi);
    if (!st[si] || hi < l || r < lo) return;
    if (lo == hi) {
      res.push_back(lo);
      st[si] = 0;
    } else {
      const int mid = (lo + hi) >> 1;
      remAll(l, r, si << 1, lo, mid, res);
      remAll(l, r, si << 1 | 1, mid + 1, hi, res);
      st[si] = V(st[si << 1], st[si << 1 | 1]);
    }
  }
  void updateAllLazy() { updateAllLazy(1, 0, n - 1); }
  void updateAllLazy(const int si, const int lo, const int hi) {
    updateLazy(si, lo, hi);
    if (lo != hi) {
      const int mid = (lo + hi) >> 1;
      updateAllLazy(si << 1, lo, mid);
      updateAllLazy(si << 1 | 1, mid + 1, hi);
    }
  }
  vector<V> retreive() {
    updateAllLazy();
    vector<V> res(n);
    for (int i = 0; i < n; ++i) res[i] = st[leaves[i]];
    return res;
  }
};
struct StVal {
  long long v = 0;
  StVal() {}
  StVal(const long long v) : v(v) {}
  StVal(const StVal& v1, const StVal& v2) { v = v1.v + v2.v; }
};
struct StUpdate {
  long long v = 0;
  StUpdate() {}
  StUpdate(const long long v) : v(v) {}
  StUpdate(const StUpdate& u1, const StUpdate& u2) { v = u1.v + u2.v; }
  void apply(StVal& v, const int lo, const int hi) {
    v.v += this->v * (hi - lo + 1);
  }
  void apply(StVal& v) { v.v += this->v; }
};
unordered_map<char, int> mp;
unordered_map<char, int> oponent;
string s;
vector<set<int>> occ;
int GetTotal(vector<SegTree<StVal, StUpdate>>& ST) {
  long long ans = 0;
  for (int i = 0; i < 3; i++) {
    int win = (i + 1) % 3;
    int loose = (i + 2) % 3;
    if (occ[loose].size() == 0) {
      ans += occ[i].size();
    } else if (occ[win].size() == 0) {
      ans += 0;
    } else {
      int winL = *occ[win].begin();
      int winR = *(--occ[win].end());
      int looseL = *occ[loose].begin();
      int looseR = *(--occ[loose].end());
      ans += ST[i].query(winL, winR).v;
      ans += ST[i].query(0, min(winL, looseL)).v;
      ans += ST[i].query(max(winR, looseR), s.size() - 1).v;
    }
  }
  return ans;
}
void Update(vector<SegTree<StVal, StUpdate>>& ST, int pos, int newType) {
  occ[mp[s[pos]]].erase(pos);
  occ[newType].insert(pos);
  ST[mp[s[pos]]].update(pos, -1);
  ST[newType].update(pos, +1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  cin >> s;
  mp['P'] = 0;
  mp['R'] = 1;
  mp['S'] = 2;
  vector<SegTree<StVal, StUpdate>> ST(3, SegTree<StVal, StUpdate>(n));
  occ.resize(3);
  for (int i = 0; i < s.size(); i++) {
    ST[mp[s[i]]].originalArray[i]++;
    occ[mp[s[i]]].insert(i);
  }
  for (int i = 0; i < 3; i++) ST[i].init();
  cout << GetTotal(ST) << "\n";
  while (q--) {
    int pj;
    char cj;
    cin >> pj >> cj;
    Update(ST, pj - 1, mp[cj]);
    s[pj - 1] = cj;
    cout << GetTotal(ST) << "\n";
  }
}
