#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 6;
int n;
char a[MAX];
bool lazy[(MAX << 2)];
struct Data {
  Data() : cnt0(0), cnt1(0), ans1(0), ans2(0) {}
  Data(char c) {
    if (c == '4')
      ++cnt0;
    else
      ++cnt1;
    ans1 = ans2 = 1;
  }
  Data(int a, int b, int c, int d) : cnt0(a), cnt1(b), ans1(c), ans2(d) {}
  void flip(int len) {
    cnt0 = len - cnt0;
    cnt1 = len - cnt1;
    swap(ans1, ans2);
  }
  int cnt0 = 0, cnt1 = 0, ans1, ans2;
} tree[(MAX << 2)];
Data Merge(const Data& a, const Data& b) {
  int cnt0 = a.cnt0 + b.cnt0;
  int cnt1 = a.cnt1 + b.cnt1;
  int ans1 = max(a.cnt0 + b.ans1, a.ans1 + b.cnt1);
  int ans2 = max(a.ans2 + b.cnt0, a.cnt1 + b.ans2);
  return Data(cnt0, cnt1, ans1, ans2);
}
void Flip(int low, int high, int pos) {
  int len = high - low + 1;
  tree[pos].flip(len);
}
void Push(int low, int high, int pos) {
  if (lazy[pos]) {
    Flip(low, high, pos);
    if (low != high) {
      lazy[(pos << 1)] ^= 1;
      lazy[(pos << 1 | 1)] ^= 1;
    }
    lazy[pos] = 0;
  }
}
void Build(int low = 1, int high = n, int pos = 1) {
  if (low == high) {
    tree[pos] = Data(a[low]);
    return;
  }
  int mid = ((low + high) >> 1);
  Build(low, mid, (pos << 1));
  Build(mid + 1, high, (pos << 1 | 1));
  tree[pos] = Merge(tree[(pos << 1)], tree[(pos << 1 | 1)]);
}
void Update(int L, int R, int low = 1, int high = n, int pos = 1) {
  Push(low, high, pos);
  if (L > high || R < low) {
    return;
  }
  if (L <= low && R >= high) {
    lazy[pos] ^= 1;
    Push(low, high, pos);
    return;
  }
  int mid = ((low + high) >> 1);
  Update(L, R, low, mid, (pos << 1));
  Update(L, R, mid + 1, high, (pos << 1 | 1));
  tree[pos] = Merge(tree[(pos << 1)], tree[(pos << 1 | 1)]);
}
int Query() {
  Push(1, n, 1);
  return tree[1].ans1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  Build();
  while (q--) {
    string s;
    cin >> s;
    if (s[0] == 's') {
      int L, R;
      cin >> L >> R;
      Update(L, R);
    } else {
      cout << Query() << "\n";
    }
  }
  return 0;
}
