#include <bits/stdc++.h>
using namespace std;
string s;
int n;
struct node {
  int ans;
  int sna;
  bool rev;
  int cnt[2];
  node() {
    rev = false;
    ans = 0;
    sna = 0;
    cnt[0] = cnt[1] = 0;
  }
  void swaptch() {
    rev ^= 1;
    swap(sna, ans);
    swap(cnt[0], cnt[1]);
  }
} t[1000100 * 4];
void shift(int v) {
  if (t[v].rev) {
    t[v + v].swaptch();
    t[v + v + 1].swaptch();
    t[v].rev = 0;
  }
}
void combine(node &p, node a, node b) {
  p.cnt[0] = a.cnt[0] + b.cnt[0];
  p.cnt[1] = a.cnt[1] + b.cnt[1];
  p.ans = max(a.cnt[0] + b.ans, a.ans + b.cnt[1]);
  p.sna = max(a.cnt[1] + b.sna, a.sna + b.cnt[0]);
}
void build(int v = 1, int tl = 1, int tr = n) {
  if (tl == tr) {
    if (s[tl - 1] == '4')
      t[v].cnt[0] = 1;
    else
      t[v].cnt[1] = 1;
    t[v].ans = t[v].sna = 1;
  } else {
    int tm = (tl + tr) >> 1;
    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);
    combine(t[v], t[v + v], t[v + v + 1]);
  }
}
void update(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (l > tr || r < tl) return;
  if (l <= tl && tr <= r) {
    t[v].swaptch();
    return;
  }
  shift(v);
  int tm = (tl + tr) >> 1;
  update(l, r, v + v, tl, tm);
  update(l, r, v + v + 1, tm + 1, tr);
  combine(t[v], t[v + v], t[v + v + 1]);
}
node get(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (l > tr || r < tl) return node();
  if (l <= tl && tr <= r) {
    return t[v];
  }
  shift(v);
  int tm = (tl + tr) >> 1;
  node res = *new node();
  combine(res, get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
  return res;
}
void solve(int TC) {
  int q;
  cin >> n >> q;
  cin >> s;
  build();
  while (q--) {
    string tp;
    cin >> tp;
    if (tp[0] == 's') {
      int l, r;
      cin >> l >> r;
      update(l, r);
    } else {
      cout << get(1, n).ans << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  solve(1);
  return 0;
}
