#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const double EPS = 1e-9;
const int MAXN = 1000000 + 1;
struct Data {
  int n4, n7, n47, n74;
  bool rev;
} tree[4 * MAXN];
char buf[MAXN];
int N, M;
void push(int v, bool leaf) {
  if (tree[v].rev) {
    tree[v].rev = false;
    swap(tree[v].n4, tree[v].n7);
    swap(tree[v].n47, tree[v].n74);
    if (!leaf) {
      tree[v << 1].rev ^= true;
      tree[v << 1 | 1].rev ^= true;
    }
  }
}
void recalc(int v) {
  tree[v].n4 = tree[v << 1].n4 + tree[v << 1 | 1].n4;
  tree[v].n7 = tree[v << 1].n7 + tree[v << 1 | 1].n7;
  tree[v].n47 = max(tree[v << 1].n4 + tree[v << 1 | 1].n47,
                    tree[v << 1].n47 + tree[v << 1 | 1].n7);
  tree[v].n74 = max(tree[v << 1].n7 + tree[v << 1 | 1].n74,
                    tree[v << 1].n74 + tree[v << 1 | 1].n4);
}
void build(int v = 1, int tl = 0, int tr = N - 1) {
  if (tl == tr) {
    if (buf[tl] == '4')
      tree[v].n4 = 1;
    else
      tree[v].n7 = 1;
    tree[v].n47 = tree[v].n74 = 1;
  } else {
    int tm = (tl + tr) >> 1;
    build(v << 1, tl, tm);
    build(v << 1 | 1, tm + 1, tr);
    recalc(v);
  }
}
void print(int v) {
  printf("%d %d %d %d     %d\n", tree[v].n4, tree[v].n7, tree[v].n47,
         tree[v].n74, tree[v].rev);
}
void Switch(int l, int r, int v = 1, int tl = 0, int tr = N - 1) {
  push(v, tl == tr);
  if (l == tl && r == tr) {
    tree[v].rev = true;
    push(v, tl == tr);
  } else {
    int tm = (tl + tr) >> 1;
    if (r <= tm)
      Switch(l, r, v << 1, tl, tm);
    else if (l > tm)
      Switch(l, r, v << 1 | 1, tm + 1, tr);
    else {
      Switch(l, tm, v << 1, tl, tm);
      Switch(tm + 1, r, v << 1 | 1, tm + 1, tr);
    }
    if (tree[v << 1].rev) push(v << 1, tl == tm);
    if (tree[v << 1 | 1].rev) push(v << 1 | 1, tm + 1 == tr);
    recalc(v);
  }
}
int Count() { return tree[1].n47; }
int main() {
  scanf("%d%d", &N, &M);
  scanf("%s", buf);
  build();
  for (int i = 0; i < M; ++i) {
    char too[10];
    scanf("%s", too);
    if (too[0] == 'c')
      printf("%d\n", Count());
    else {
      int l, r;
      scanf("%d%d", &l, &r);
      Switch(l - 1, r - 1);
    }
  }
  return 0;
}
