#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T>& p) {
  return out << "{" << p.first << ", " << p.second << "}";
}
template <typename I>
class iter_type {
 public:
  const I b, e;
  iter_type(I b, I e) : b(b), e(e) {}
};
template <typename I>
iter_type<I> iter(I b, I e) {
  return iter_type<I>(b, e);
}
template <typename T>
auto iter(T& v) -> iter_type<decltype(begin(v))> {
  return iter_type<decltype(begin(v))>(begin(v), end(v));
}
template <typename I>
ostream& operator<<(ostream& out, const iter_type<I>& x) {
  out << "[";
  for (I it = x.b; it != x.e; ++it) {
    out << *it;
    if (next(it) != x.e) {
      out << ", ";
    }
  }
  return out << "]";
}
template <typename I>
istream& operator>>(istream& in, const iter_type<I>& x) {
  for (I it = x.b; it != x.e; ++it) {
    in >> *it;
  }
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  return out << iter(v);
}
template <typename T>
istream& operator>>(istream& in, vector<T>& v) {
  return in >> iter(v);
}
template <typename T>
ostream& operator<<(ostream& out, const set<T>& v) {
  return out << iter(v);
}
template <typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& v) {
  return out << iter(v);
}
template <typename T>
ostream& operator<<(ostream& out, const unordered_set<T>& v) {
  return out << iter(v);
}
template <typename S, typename T>
ostream& operator<<(ostream& out, const unordered_map<S, T>& v) {
  return out << iter(v);
}
class fenwick_t {
  int N;
  vector<int> ft;

 public:
  fenwick_t(int N_) : N(N_ + 1), ft(N + 1, 0) {}
  int query(int w) {
    ++w;
    int ans = 0;
    for (; w; w -= w & (-w)) {
      ans += ft[w];
    }
    return ans;
  }
  void update(int w, int v) {
    ++w;
    for (; w <= N; w += w & (-w)) {
      ft[w] += v;
    }
  }
};
int char_to_int[300];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  set<int> A[3];
  memset(char_to_int, -1, sizeof(char_to_int));
  char_to_int['P'] = 0;
  char_to_int['R'] = 1;
  char_to_int['S'] = 2;
  vector<fenwick_t> ft;
  for (int i = 0; i < 3; ++i) {
    ft.emplace_back(N);
  }
  for (int n = 0; n < N; ++n) {
    int i = char_to_int[S[n]];
    A[i].insert(n);
    ft[i].update(n, 1);
  }
  for (int q = 0; q <= Q; ++q) {
    int ans = N;
    for (int i = 0; i < 3; ++i) {
      if (A[(i + 2) % 3].size()) {
        if (A[(i + 1) % 3].size()) {
          int l1 = *A[(i + 2) % 3].begin(), r2 = *A[(i + 2) % 3].rbegin();
          int l2 = *A[(i + 1) % 3].begin(), r1 = *A[(i + 1) % 3].rbegin();
          if (l1 < l2) {
            ans -= ft[i].query(l2) - ft[i].query(l1);
          }
          if (r1 < r2) {
            ans -= ft[i].query(r2) - ft[i].query(r1);
          }
        } else {
          ans -= ft[i].query(N - 1);
        }
      }
    }
    cout << ans << "\n";
    if (q < Q) {
      int n;
      char c;
      cin >> n >> c;
      --n;
      int i = char_to_int[S[n]], j = char_to_int[c];
      S[n] = c;
      A[i].erase(n);
      A[j].insert(n);
      ft[i].update(n, -1);
      ft[j].update(n, 1);
    }
  }
  return 0;
}
