#include <bits/stdc++.h>
using namespace std;
const long long inf = (1LL << 50);
const int mxn = 1000000 + 10;
string s;
int n;
int Z[4 * mxn];
int O[4 * mxn];
int I[4 * mxn];
int D[4 * mxn];
int P[4 * mxn];
void shift(int c, int b, int e) {
  if (b == e) return;
  int l = 2 * c;
  int r = l + 1;
  P[l] ^= 1;
  P[r] ^= 1;
  swap(O[l], Z[l]);
  swap(I[l], D[l]);
  swap(O[r], Z[r]);
  swap(I[r], D[r]);
  P[c] = 0;
  return;
}
void update(int first, int second, int c = 1, int b = 0, int e = n - 1) {
  if (second < b or e < first) return;
  if (P[c] == 1) shift(c, b, e);
  if (first <= b and e <= second) {
    P[c] ^= 1;
    swap(O[c], Z[c]);
    swap(I[c], D[c]);
    return;
  }
  int m = (b + e) / 2;
  int l = 2 * c;
  int r = l + 1;
  update(first, second, l, b, m);
  update(first, second, r, m + 1, e);
  Z[c] = Z[l] + Z[r];
  O[c] = O[l] + O[r];
  I[c] = max(Z[l] + I[r], I[l] + O[r]);
  D[c] = max(O[l] + D[r], D[l] + Z[r]);
  return;
}
void build(int c = 1, int b = 0, int e = n - 1) {
  if (b == e) {
    if (s[b] == '4')
      Z[c] = 1;
    else
      O[c] = 1;
    I[c] = D[c] = 1;
    return;
  }
  int m = (b + e) / 2;
  int l = 2 * c;
  int r = l + 1;
  build(l, b, m);
  build(r, m + 1, e);
  Z[c] = Z[l] + Z[r];
  O[c] = O[l] + O[r];
  I[c] = max(Z[l] + I[r], I[l] + O[r]);
  D[c] = max(O[l] + D[r], D[l] + Z[r]);
  return;
}
int main(int argc, char const *argv[]) {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> n >> q;
  cin >> s;
  build();
  for (int i = 1; i <= q; i++) {
    int first, second;
    string e;
    cin >> e;
    if (e == "count") {
      cout << I[1] << '\n';
    } else {
      cin >> first >> second;
      update(--first, --second);
    }
  }
  cout.flush();
  return 0;
}
