#include <bits/stdc++.h>
using namespace std;
const int64_t N = 1e6 + 10;
int64_t n, q;
bool lazy[4 * N], a[N];
string op;
int64_t second[4 * N][4], ans[4];
vector<pair<int64_t, int64_t> > v;
inline void mergechild(int64_t id) {
  int64_t lc = 2 * id, rc = 2 * id + 1;
  second[id][0] = second[lc][0] + second[rc][0];
  second[id][1] = second[lc][1] + second[rc][1];
  second[id][2] =
      max(second[lc][0] + second[rc][2], second[lc][2] + second[rc][1]);
  second[id][3] =
      max(second[lc][1] + second[rc][3], second[lc][3] + second[rc][0]);
}
inline void build(int64_t id = 1, int64_t l = 0, int64_t r = n) {
  if (r - l == 1) {
    (a[l] ? second[id][1] = 1 : second[id][0] = 1);
    second[id][2] = 1;
    second[id][3] = 1;
    return;
  }
  int64_t mid = (l + r) >> 1;
  build(2 * id, l, mid);
  build(2 * id + 1, mid, r);
  mergechild(id);
}
inline void upc(int64_t id) {
  swap(second[id][0], second[id][1]);
  swap(second[id][2], second[id][3]);
  lazy[id] ^= 1;
}
inline void shift(int64_t id) {
  if (!lazy[id]) {
    return;
  }
  upc(2 * id);
  upc(2 * id + 1);
  lazy[id] ^= 1;
}
inline void swc(int64_t le, int64_t ri, int64_t id = 1, int64_t l = 0,
                int64_t r = n) {
  if (r <= le || ri <= l) {
    return;
  }
  if (l >= le && r <= ri) {
    upc(id);
    return;
  }
  int64_t mid = (l + r) >> 1;
  shift(id);
  swc(le, ri, 2 * id, l, mid);
  swc(le, ri, 2 * id + 1, mid, r);
  mergechild(id);
}
string st;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> st;
  for (int64_t i = 0; i < n; i++) {
    a[i] = (st[i] - '0') & 1;
  }
  build();
  int64_t l, r;
  while (q--) {
    cin >> op;
    if (op == "switch") {
      cin >> l >> r;
      l--;
      swc(l, r);
      continue;
    }
    cout << second[1][2] << '\n';
  }
}
