#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000001;
int n;
struct node {
  int uplen, downlen;
  int cnt0, cnt1;
  bool inv;
};
node tree[4 * MAXN];
void Merge(node &p, node &a, node &b) {
  p.uplen = max(a.cnt0 + b.uplen, a.uplen + b.cnt1);
  p.downlen = max(a.downlen + b.cnt0, a.cnt1 + b.downlen);
  p.cnt0 = a.cnt0 + b.cnt0;
  p.cnt1 = a.cnt1 + b.cnt1;
}
void upd(int v) {
  tree[v].inv ^= 1;
  swap(tree[v].cnt0, tree[v].cnt1);
  swap(tree[v].uplen, tree[v].downlen);
}
void push(int v) {
  if (!tree[v].inv || (v << 1 | 1) >= 4 * n) return;
  upd(v << 1);
  upd(v << 1 | 1);
  tree[v].inv = 0;
}
void build(int tl, int tr, int v, bool *a) {
  if (tl == tr) {
    tree[v].uplen = tree[v].downlen = 1;
    tree[v].cnt0 = (a[tl] == 0 ? 1 : 0);
    tree[v].cnt1 = !tree[v].cnt0;
    tree[v].inv = 0;
    return;
  }
  int mid = (tl + tr) >> 1;
  build(tl, mid, v << 1, a);
  build(mid + 1, tr, v << 1 | 1, a);
  Merge(tree[v], tree[v << 1], tree[v << 1 | 1]);
}
void update(int tl, int tr, int v, int l, int r) {
  if (l > tr || r < tl) return;
  if (l <= tl && tr <= r) {
    upd(v);
    return;
  }
  push(v);
  int mid = (tl + tr) >> 1;
  update(tl, mid, v << 1, l, r);
  update(mid + 1, tr, v << 1 | 1, l, r);
  Merge(tree[v], tree[v << 1], tree[v << 1 | 1]);
}
inline int query() {
  push(1);
  return tree[1].uplen;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m;
  cin >> n >> m;
  bool *a = new bool[n];
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    a[i] = (c == '4' ? 0 : 1);
  }
  build(0, n - 1, 1, a);
  while (m--) {
    string type;
    cin >> type;
    if (type == "switch") {
      int left, right;
      cin >> left >> right;
      left--, right--;
      update(0, n - 1, 1, left, right);
    } else
      cout << query() << '\n';
  }
  return 0;
}
