#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, q;
string s;
int total[N], start[N];
int main() {
cin.tie(nullptr)->ios_base::sync_with_stdio(false);
cin >> n >> q >> s;
for (int i = 1; i <= n; i++) {
if (s[i-1] == '0') start[i] = -1;
else start[i] = 0;
}
for (int i = 1; i <= q; i++) {
string type;
cin >> type;
if (type == "toggle") {
int pos;
cin >> pos;
if (start[pos] == -1) start[pos] = i;
else {
total[pos] += i - start[pos];
start[pos] = -1;
}
}
else {
int a, b;
cin >> a >> b;
if (start[a] == -1) cout << total[a] << "\n";
else cout << total[a] + i - start[a] << "\n";
}
}
}