#include <bits/stdc++.h>
using namespace std;
int n4[4100000], n7[4100000], mx[4100000], my[4100000], sign[4100000];
int x, y;
char s[1200000];
void modify(int p) {
  sign[p] = 1 - sign[p];
  swap(n4[p], n7[p]);
  swap(mx[p], my[p]);
}
void update(int p) {
  if (sign[p]) {
    sign[p] = 0;
    modify(p << 1);
    modify((p << 1) + 1);
  }
}
void refresh(int p) {
  int x = p << 1, y = x + 1;
  n4[p] = n4[x] + n4[y];
  n7[p] = n7[x] + n7[y];
  mx[p] = max(mx[x] + n7[y], n4[x] + mx[y]);
  my[p] = max(my[x] + n4[y], n7[x] + my[y]);
}
void buildTree(int p, int l, int r) {
  if (l == r) {
    n4[p] = s[l] == '4';
    n7[p] = s[l] == '7';
    mx[p] = 1, my[p] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  buildTree(p << 1, l, mid);
  buildTree((p << 1) + 1, mid + 1, r);
  refresh(p);
}
void change(int p, int l, int r) {
  if (l >= x && r <= y) {
    modify(p);
    return;
  }
  update(p);
  int mid = (l + r) >> 1;
  if (x <= mid) change(p << 1, l, mid);
  if (y > mid) change((p << 1) + 1, mid + 1, r);
  refresh(p);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  buildTree(1, 1, n);
  while (m--) {
    scanf("%s", s);
    if (*s == 'c')
      printf("%d\n", mx[1]);
    else {
      scanf("%d%d", &x, &y);
      change(1, 1, n);
    }
  }
}
