#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 10;
string s, qs;
struct NODE {
  int fours, sevens, inc, dec;
} tree[MAX * 4];
int lazy[MAX * 4];
NODE merge(NODE &a, NODE &b) {
  NODE r;
  r.fours = a.fours + b.fours;
  r.sevens = a.sevens + b.sevens;
  r.inc = max(a.inc + b.sevens, a.fours + b.inc);
  r.dec = max(a.dec + b.fours, a.sevens + b.dec);
  return r;
}
void build_tree(int node, int i, int j) {
  if (i == j) {
    char c = s[i - 1];
    tree[node].dec = tree[node].inc = 1;
    if (c == '4')
      tree[node].fours = 1;
    else
      tree[node].sevens = 1;
    return;
  }
  int mid = (i + j) / 2;
  build_tree(node * 2, i, mid);
  build_tree(node * 2 + 1, mid + 1, j);
  tree[node] = merge(tree[node * 2], tree[node * 2 + 1]);
}
NODE change(NODE &a) {
  NODE r;
  r.fours = a.sevens;
  r.sevens = a.fours;
  r.inc = a.dec;
  r.dec = a.inc;
  return r;
}
void update(int node, int i, int j, int a, int b) {
  if (lazy[node]) {
    tree[node] = change(tree[node]);
    if (i != j) {
      lazy[node * 2] = !lazy[node * 2];
      lazy[node * 2 + 1] = !lazy[node * 2 + 1];
    }
    lazy[node] = 0;
  }
  if (i > j || j < a || b < i) return;
  if (a <= i && j <= b) {
    lazy[node] = !lazy[node];
    if (i != j) {
      lazy[node * 2] = !lazy[node * 2];
      lazy[node * 2 + 1] = !lazy[node * 2 + 1];
    }
    if (lazy[node]) {
      tree[node] = change(tree[node]);
      lazy[node] = 0;
    }
    return;
  }
  int mid = (i + j) / 2;
  update(node * 2, i, mid, a, b);
  update(node * 2 + 1, mid + 1, j, a, b);
  tree[node] = merge(tree[node * 2], tree[node * 2 + 1]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  cin >> s;
  build_tree(1, 1, n);
  for (int(i) = (0); (i) < (q); (i)++) {
    cin >> qs;
    if (qs[0] == 'c') {
      cout << (tree[1].inc) << "\n";
      ;
    } else {
      int l, r;
      cin >> l >> r;
      update(1, 1, n, l, r);
    }
  }
}
