#include <bits/stdc++.h>
using namespace std;
char str[1000006];
char ch[1000006];
struct point {
  long long four, seven, inc, dec;
} tree[4 * 1000006];
long long lazy[4 * 1000006];
void build(long long node, long long lo, long long hi) {
  if (lo == hi) {
    if (str[lo] == '4') {
      tree[node].four++;
    } else
      tree[node].seven++;
    tree[node].inc = 1;
    tree[node].dec = 1;
    return;
  }
  long long mid = lo + hi;
  mid /= 2;
  build(node * 2, lo, mid);
  build(node * 2 + 1, mid + 1, hi);
  tree[node].four = tree[node * 2].four + tree[node * 2 + 1].four;
  tree[node].seven = tree[node * 2].seven + tree[node * 2 + 1].seven;
  tree[node].inc = max(tree[node * 2].four + tree[node * 2 + 1].inc,
                       tree[node * 2].inc + tree[node * 2 + 1].seven);
  tree[node].dec = max(tree[node * 2].seven + tree[node * 2 + 1].dec,
                       tree[node * 2].dec + tree[node * 2 + 1].four);
  return;
}
void propagate(long long node, long long lo, long long hi) {
  if (lo != hi) {
    lazy[node * 2] = 1 - lazy[node * 2];
    lazy[node * 2 + 1] = 1 - lazy[node * 2 + 1];
    lazy[node] = 0;
    swap(tree[node * 2].four, tree[node * 2].seven);
    swap(tree[node * 2 + 1].four, tree[node * 2 + 1].seven);
    swap(tree[node * 2].inc, tree[node * 2].dec);
    swap(tree[node * 2 + 1].inc, tree[node * 2 + 1].dec);
  }
}
void update(long long node, long long lo, long long hi, long long l,
            long long r) {
  if (lo > r || hi < l) return;
  if (lo >= l && hi <= r) {
    swap(tree[node].four, tree[node].seven);
    swap(tree[node].inc, tree[node].dec);
    lazy[node] = 1 - lazy[node];
    return;
  }
  if (lazy[node]) propagate(node, lo, hi);
  long long mid = lo + hi;
  mid /= 2;
  update(node * 2, lo, mid, l, r);
  update(node * 2 + 1, mid + 1, hi, l, r);
  tree[node].four = tree[node * 2].four + tree[node * 2 + 1].four;
  tree[node].seven = tree[node * 2].seven + tree[node * 2 + 1].seven;
  tree[node].inc = max(tree[node * 2].four + tree[node * 2 + 1].inc,
                       tree[node * 2].inc + tree[node * 2 + 1].seven);
  tree[node].dec = max(tree[node * 2].seven + tree[node * 2 + 1].dec,
                       tree[node * 2].dec + tree[node * 2 + 1].four);
}
int main() {
  long long n, q;
  scanf("%lld", &n);
  scanf("%lld", &q);
  scanf("%s", ch);
  for (long long i = 0; i < n; i++) {
    str[i + 1] = ch[i];
  }
  build(1, 1, n);
  for (long long i = 1; i <= q; i++) {
    scanf("%s", ch);
    if (ch[0] == 's') {
      long long u, v;
      scanf("%lld", &u);
      scanf("%lld", &v);
      update(1, 1, n, u, v);
    } else
      printf("%lld\n", tree[1].inc);
  }
}
