#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int a = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) a = a * 10 + (ch ^ 48), ch = getchar();
  return a * f;
}
int n, m, a[1000009];
char s[1000009];
int tag[1000009 << 2], val[1000009 << 2][4];
void pushup(int p) {
  val[p][0] = val[(p << 1)][0] + val[(p << 1 | 1)][0];
  val[p][1] = val[(p << 1)][1] + val[(p << 1 | 1)][1];
  val[p][2] =
      max(max(val[(p << 1)][0], val[(p << 1)][2]) + val[(p << 1 | 1)][1],
          max(val[(p << 1 | 1)][1], val[(p << 1 | 1)][2]) + val[(p << 1)][0]);
  val[p][3] =
      max(max(val[(p << 1)][1], val[(p << 1)][3]) + val[(p << 1 | 1)][0],
          max(val[(p << 1 | 1)][0], val[(p << 1 | 1)][3]) + val[(p << 1)][1]);
}
void build(int l, int r, int p) {
  if (l == r) return val[p][a[l]] = val[p][2] = val[p][3] = 1, void();
  int mid = (l + r) >> 1;
  build(l, mid, (p << 1)), build(mid + 1, r, (p << 1 | 1));
  pushup(p);
}
void addtag(int p) {
  tag[p] ^= 1, swap(val[p][0], val[p][1]), swap(val[p][2], val[p][3]);
}
void pushdown(int p, int l, int r) {
  if (tag[p]) addtag((p << 1)), addtag((p << 1 | 1)), tag[p] ^= 1;
}
void update(int ql, int qr, int l, int r, int p) {
  if (ql <= l && r <= qr) return addtag(p), void();
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  if (ql <= mid) update(ql, qr, l, mid, (p << 1));
  if (qr > mid) update(ql, qr, mid + 1, r, (p << 1 | 1));
  pushup(p);
}
signed main() {
  n = rd(), m = rd(), scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) a[i] = s[i] == '7';
  build(1, n, 1);
  while (m--) {
    scanf("%s", s);
    int opt = s[0] == 's', x, y;
    if (opt)
      x = rd(), y = rd(), update(x, y, 1, n, 1);
    else
      printf("%d\n", val[1][2]);
  }
  return 0;
}
