#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1e6 + 5;
int n;
string s;
struct node {
  int fours, sevens, inc, dec;
  node operator+(node rhs) {
    return {fours + rhs.fours, sevens + rhs.sevens,
            max(fours + rhs.inc, inc + rhs.sevens),
            max(sevens + rhs.dec, dec + rhs.fours)};
  }
  node operator!() { return {sevens, fours, dec, inc}; }
} tree[N << 2];
bool lazy[N << 2];
void build(int b = 1, int e = n + 1, int idx = 1) {
  if (b + 1 == e) {
    tree[idx] = {s[b - 1] == '4', s[b - 1] == '7', 1, 1};
    return;
  }
  int m = (b + e) >> 1;
  build(b, m, idx << 1 | 0);
  build(m, e, idx << 1 | 1);
  tree[idx] = tree[idx << 1 | 0] + tree[idx << 1 | 1];
}
void update(int l, int r, int b = 1, int e = n + 1, int idx = 1) {
  if (b == l and r == e) {
    tree[idx] = !tree[idx];
    lazy[idx] ^= 1;
    return;
  }
  if (lazy[idx]) {
    lazy[idx] = false;
    lazy[idx << 1 | 0] ^= 1;
    lazy[idx << 1 | 1] ^= 1;
    tree[idx << 1 | 0] = !tree[idx << 1 | 0];
    tree[idx << 1 | 1] = !tree[idx << 1 | 1];
  }
  int m = (b + e) >> 1;
  if (l < m) update(l, min(m, r), b, m, idx << 1 | 0);
  if (r > m) update(max(m, l), r, m, e, idx << 1 | 1);
  tree[idx] = tree[idx << 1 | 0] + tree[idx << 1 | 1];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m;
  cin >> n >> m >> s;
  build();
  while (m--) {
    string cmd;
    cin >> cmd;
    if (cmd[0] == 's') {
      int l, r;
      cin >> l >> r;
      update(l, r + 1);
    } else {
      cout << tree[1].inc << '\n';
    }
  }
}
