#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
char s[N];
int n, m, I[N << 2], D[N << 2], T[N << 2][2], rev[N << 2];
void up(int x) {
  T[x][0] = T[x << 1][0] + T[x << 1 | 1][0];
  T[x][1] = T[x << 1][1] + T[x << 1 | 1][1];
  I[x] = max(I[x << 1] + T[x << 1 | 1][1], T[x << 1][0] + I[x << 1 | 1]);
  D[x] = max(D[x << 1] + T[x << 1 | 1][0], T[x << 1][1] + D[x << 1 | 1]);
}
void reverse(int x) {
  rev[x] ^= 1;
  swap(T[x][0], T[x][1]);
  swap(I[x], D[x]);
}
void pb(int x) {
  if (rev[x]) {
    reverse(x << 1);
    reverse(x << 1 | 1);
    rev[x] = 0;
  }
}
void build(int x, int l, int r) {
  I[x] = D[x] = T[x][0] = T[x][1] = 0;
  if (l == r) {
    I[x] = D[x] = 1;
    T[x][0] = s[l] == '4';
    T[x][1] = s[l] == '7';
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  up(x);
}
void change(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    reverse(x);
    return;
  }
  int mid = (l + r) >> 1;
  pb(x);
  if (L <= mid) change(x << 1, l, mid, L, R);
  if (mid < R) change(x << 1 | 1, mid + 1, r, L, R);
  up(x);
}
char op[10];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  build(1, 1, n);
  while (m--) {
    scanf("%s", op);
    if (op[0] == 'c')
      printf("%d\n", I[1]);
    else {
      int l, r;
      scanf("%d%d", &l, &r);
      change(1, 1, n, l, r);
    }
  }
  return 0;
}
