#include <bits/stdc++.h>
const int Maxn = 1e6 + 5;
using namespace std;
inline int R() {
  char c;
  int res;
  while ((c = getchar()) > '9' || c < '0')
    ;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  return res;
}
int n, c[Maxn], up[Maxn * 4], tag[Maxn * 4], down[Maxn * 4], F[Maxn * 4],
    S[Maxn * 4], m;
void W(int x) {
  if (x > 9) W(x / 10);
  putchar('0' + x % 10);
}
inline int Max(int a, int b, int c) {
  if (a >= b && a >= c) return a;
  if (b >= a && b >= c) return b;
  return c;
}
inline void pushup(int root) {
  F[root] = F[(root << 1)] + F[(root << 1 | 1)];
  S[root] = S[(root << 1)] + S[(root << 1 | 1)];
  up[root] = Max(F[(root << 1)] + S[(root << 1 | 1)],
                 up[(root << 1)] + S[(root << 1 | 1)],
                 F[(root << 1)] + up[(root << 1 | 1)]);
  down[root] = Max(S[(root << 1)] + F[(root << 1 | 1)],
                   down[(root << 1)] + F[(root << 1 | 1)],
                   S[(root << 1)] + down[(root << 1 | 1)]);
}
void build(int root, int l, int r) {
  if (l == r) {
    if (c[r] == 4)
      F[root] = 1;
    else
      S[root] = 1;
    down[root] = up[root] = 1;
    return;
  }
  build((root << 1), l, (l + r >> 1));
  build((root << 1 | 1), (l + r >> 1) + 1, r);
  pushup(root);
}
inline void rev(int root) {
  tag[root] ^= 1;
  swap(up[root], down[root]);
  swap(F[root], S[root]);
}
inline void pushdown(int root) {
  if (!tag[root]) return;
  tag[root] = 0;
  rev((root << 1));
  rev((root << 1 | 1));
}
void modify(int root, int l, int r, int z, int y) {
  if (l > y || r < z) return;
  if (l >= z && r <= y) return rev(root);
  pushdown(root);
  modify((root << 1), l, (l + r >> 1), z, y);
  modify((root << 1 | 1), (l + r >> 1) + 1, r, z, y);
  pushup(root);
}
int main() {
  n = R();
  m = R();
  char op;
  int x, y;
  for (int i = 1; i <= n; i++) {
    while ((op = getchar()) != '4' && op != '7')
      ;
    c[i] = op - '0';
  }
  build(1, 1, n);
  char s[101];
  for (int i = 1; i <= m; i++) {
    scanf("%s", s);
    if (s[0] == 'c') {
      W(up[1]);
      puts("");
    };
    if (s[0] == 's') {
      x = R();
      y = R();
      modify(1, 1, n, x, y);
    }
  }
}
