#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 100, MOD = 1e9 + 9, INF = 1e15, SQ = 370, LOG = 30;
int n, m, x, y, x2, y2, z, t, now, l, r;
int ans, dp[4][4 * N];
bool lazy[4 * N];
string s;
void bld(int b, int e, int pos) {
  if (b == e - 1) {
    if (s[b] == '7') {
      dp[3][pos]++;
    } else {
      dp[2][pos]++;
    }
    dp[0][pos] = dp[1][pos] = 1;
    return;
  }
  int lch = pos << 1, rch = lch + 1, mid = e + b >> 1;
  bld(b, mid, lch);
  bld(mid, e, rch);
  dp[3][pos] = dp[3][lch] + dp[3][rch];
  dp[2][pos] = dp[2][lch] + dp[2][rch];
  dp[1][pos] = max(dp[3][lch] + dp[1][rch], dp[1][lch] + dp[2][rch]);
  dp[0][pos] = max(dp[2][lch] + dp[0][rch], dp[0][lch] + dp[3][rch]);
}
void shift(int pos, int lch, int rch) {
  lazy[lch] = !lazy[lch];
  lazy[rch] = !lazy[rch];
  lazy[pos] = false;
  swap(dp[0][lch], dp[1][lch]);
  swap(dp[2][lch], dp[3][lch]);
  swap(dp[0][rch], dp[1][rch]);
  swap(dp[2][rch], dp[3][rch]);
}
void upd(int b, int e, int pos) {
  if (b >= y || e <= x) return;
  if (x <= b && e <= y) {
    lazy[pos] = !lazy[pos];
    swap(dp[0][pos], dp[1][pos]);
    swap(dp[2][pos], dp[3][pos]);
    return;
  }
  int lch = pos << 1, rch = lch + 1, mid = e + b >> 1;
  if (lazy[pos]) shift(pos, lch, rch);
  upd(b, mid, lch);
  upd(mid, e, rch);
  dp[3][pos] = dp[3][lch] + dp[3][rch];
  dp[2][pos] = dp[2][lch] + dp[2][rch];
  dp[1][pos] = max(dp[3][lch] + dp[1][rch], dp[1][lch] + dp[2][rch]);
  dp[0][pos] = max(dp[2][lch] + dp[0][rch], dp[0][lch] + dp[3][rch]);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> s;
  bld(0, n, 1);
  while (m--) {
    cin >> s;
    if (s == "count") {
      cout << dp[0][1] << '\n';
    } else {
      cin >> x >> y;
      x--;
      upd(0, n, 1);
    }
  }
}
