#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 1e6 + 10, L = 20;
int n, m;
string str;
struct segmentTree {
  int best, seq[2][2];
  bool changed;
  segmentTree() {
    best = seq[0][0] = seq[0][1] = seq[1][1] = seq[1][0] = 0;
    changed = false;
  }
} node[N << 2];
inline void update(segmentTree &par, segmentTree &c1, segmentTree &c2) {
  par.seq[0][0] = c1.seq[0][0] + c2.seq[0][0];
  par.seq[1][1] = c1.seq[1][1] + c2.seq[1][1];
  par.seq[0][1] =
      max(c1.seq[0][0] + c2.seq[1][1],
          max(c1.seq[0][1] + c2.seq[1][1], c1.seq[0][0] + c2.seq[0][1]));
  par.seq[1][0] =
      max(c1.seq[1][1] + c2.seq[0][0],
          max(c1.seq[1][1] + c2.seq[1][0], c1.seq[1][0] + c2.seq[0][0]));
  par.best = max(max(par.seq[0][0], par.seq[1][1]), par.seq[0][1]);
}
inline void propagate(int id, int s, int e) {
  if (!node[id].changed) return;
  node[id].changed = false;
  node[id * 2].changed ^= 1;
  node[id * 2 + 1].changed ^= 1;
  swap(node[id * 2].seq[0][0], node[id * 2].seq[1][1]);
  swap(node[id * 2].seq[0][1], node[id * 2].seq[1][0]);
  node[id * 2].best = max(max(node[id * 2].seq[0][0], node[id * 2].seq[1][1]),
                          node[id * 2].seq[0][1]);
  swap(node[id * 2 + 1].seq[0][0], node[id * 2 + 1].seq[1][1]);
  swap(node[id * 2 + 1].seq[0][1], node[id * 2 + 1].seq[1][0]);
  node[id * 2 + 1].best =
      max(max(node[id * 2 + 1].seq[0][0], node[id * 2 + 1].seq[1][1]),
          node[id * 2 + 1].seq[0][1]);
}
void buildTree(int s, int e, int id) {
  if (s + 1 == e) {
    if (str[s] == '4')
      node[id].seq[0][0] = node[id].seq[0][0] = node[id].best = 1;
    else
      node[id].seq[1][1] = node[id].seq[1][1] = node[id].best = 1;
    return;
  }
  int mid = (s + e) >> 1;
  buildTree(s, mid, id * 2);
  buildTree(mid, e, id * 2 + 1);
  update(node[id], node[id * 2], node[id * 2 + 1]);
}
void modify(int s, int e, int id, int l, int r) {
  if (s >= r || e <= l || l >= r) return;
  if (s >= l && e <= r) {
    node[id].changed ^= 1;
    swap(node[id].seq[0][0], node[id].seq[1][1]);
    swap(node[id].seq[0][1], node[id].seq[1][0]);
    node[id].best =
        max(max(node[id].seq[0][0], node[id].seq[1][1]), node[id].seq[0][1]);
    return;
  }
  propagate(id, s, e);
  int mid = (s + e) >> 1;
  modify(s, mid, id * 2, l, r);
  modify(mid, e, id * 2 + 1, l, r);
  update(node[id], node[id * 2], node[id * 2 + 1]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> str;
  buildTree(0, n, 1);
  for (; m; m--) {
    string q;
    cin >> q;
    if (q == "switch") {
      int l, r;
      cin >> l >> r;
      modify(0, n, 1, l - 1, r);
    } else
      cout << node[1].best << endl;
  }
  return 0;
}
