#include <bits/stdc++.h>
using namespace std;
vector<int> res;
class segtree {
 public:
  struct node {
    int r = 0, s = 0, p = 0;
    void apply(char u) {
      r = 0, s = 0, p = 0;
      if (u == 'R') r = 1;
      if (u == 'P') p = 1;
      if (u == 'S') s = 1;
    }
  };
  node unite(const node &a, const node &b) {
    node res;
    res.r = a.r + b.r;
    res.s = a.s + b.s;
    res.p = a.p + b.p;
    return res;
  }
  inline void pull(int x, int z) { tree[x] = unite(tree[x + 1], tree[z]); }
  int n;
  vector<node> tree;
  template <typename M>
  void build(int x, int l, int r, const vector<M> &v) {
    if (l == r) {
      tree[x].apply(v[l]);
      return;
    }
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    build(x + 1, l, y, v);
    build(z, y + 1, r, v);
    pull(x, z);
  }
  node get(int x, int l, int r, int ll, int rr) {
    if (l >= ll && rr >= r) {
      return tree[x];
    }
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    node res{};
    if (rr <= y) {
      res = get(x + 1, l, y, ll, rr);
    } else {
      if (ll > y) {
        res = get(z, y + 1, r, ll, rr);
      } else {
        res = unite(get(x + 1, l, y, ll, rr), get(z, y + 1, r, ll, rr));
      }
    }
    return res;
  }
  node get(int l, int r) {
    assert(0 <= l && l <= r && r <= n - 1);
    return get(0, 0, n - 1, l, r);
  }
  void modify(int x, int l, int r, int p, char u) {
    if (l == r) {
      tree[x].apply(u);
      return;
    }
    int y = (l + r) >> 1;
    int z = x + ((y - l + 1) << 1);
    if (p <= y) {
      modify(x + 1, l, y, p, u);
    } else {
      modify(z, y + 1, r, p, u);
    }
    pull(x, z);
  }
  template <typename M>
  segtree(const vector<M> &v) {
    n = v.size();
    assert(n > 0);
    tree.resize(2 * n - 1);
    build(0, 0, n - 1, v);
  }
};
set<int> rock, paper, scissor;
int n, q;
string tour;
vector<char> har;
char in[200005];
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", &in);
  tour = in;
  for (int i = 0; i < n; i++) har.push_back(tour[i]);
  for (int i = 0; i < n; i++) {
    if (tour[i] == 'R') rock.insert(i);
    if (tour[i] == 'P') paper.insert(i);
    if (tour[i] == 'S') scissor.insert(i);
  }
  segtree rev(har);
  auto calc = [&]() {
    int res = 0;
    {
      if (!scissor.size() && !paper.size()) res += n;
      if (scissor.size() > 0) {
        if (paper.size() > 0) {
          int u = *scissor.begin(), v = *scissor.rbegin(), s = *paper.begin(),
              t = *paper.rbegin();
          res += rev.get(0, min(u, s)).r + rev.get(max(v, t), n - 1).r +
                 rev.get(u, v).r;
        } else
          res += n - scissor.size();
      }
    }
    {
      if (!paper.size() && !rock.size()) res += n;
      if (paper.size() > 0) {
        if (rock.size() > 0) {
          int u = *paper.begin(), v = *paper.rbegin(), s = *rock.begin(),
              t = *rock.rbegin();
          res += rev.get(0, min(u, s)).s + rev.get(max(v, t), n - 1).s +
                 rev.get(u, v).s;
        } else
          res += n - paper.size();
      }
    }
    {
      if (!rock.size() && !scissor.size()) res += n;
      if (rock.size() > 0) {
        if (scissor.size() > 0) {
          int u = *rock.begin(), v = *rock.rbegin(), s = *scissor.begin(),
              t = *scissor.rbegin();
          res += rev.get(0, min(u, s)).p + rev.get(max(v, t), n - 1).p +
                 rev.get(u, v).p;
        } else
          res += n - rock.size();
      }
    }
    return res;
  };
  res.push_back(calc());
  while (q--) {
    int i;
    char u;
    scanf("%d", &i);
    scanf(" %c", &u);
    i--;
    if (tour[i] == 'R') rock.erase(i);
    if (tour[i] == 'P') paper.erase(i);
    if (tour[i] == 'S') scissor.erase(i);
    tour[i] = u;
    rev.modify(0, 0, n - 1, i, u);
    if (u == 'R') rock.insert(i);
    if (u == 'P') paper.insert(i);
    if (u == 'S') scissor.insert(i);
    res.push_back(calc());
  }
  for (auto i : res) cout << i << endl;
  return 0;
}
