Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Lucky Queries

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya brought home string *s* with the length of *n*. The string only consists of lucky digits. The digits are numbered from the left to the right starting with 1. Now Petya should execute *m* queries of the following form:

- switch
*l**r*— "switch" digits (i.e. replace them with their opposites) at all positions with indexes from*l*to*r*, inclusive: each digit 4 is replaced with 7 and each digit 7 is replaced with 4 (1 ≤*l*≤*r*≤*n*); - count — find and print on the screen the length of the longest non-decreasing subsequence of string
*s*.

Subsequence of a string *s* is a string that can be obtained from *s* by removing zero or more of its elements. A string is called non-decreasing if each successive digit is not less than the previous one.

Help Petya process the requests.

Input

The first line contains two integers *n* and *m* (1 ≤ *n* ≤ 10^{6}, 1 ≤ *m* ≤ 3·10^{5}) — the length of the string *s* and the number of queries correspondingly. The second line contains *n* lucky digits without spaces — Petya's initial string. Next *m* lines contain queries in the form described in the statement.

Output

For each query count print an answer on a single line.

Examples

Input

2 3

47

count

switch 1 2

count

Output

2

1

Input

3 5

747

count

switch 1 1

count

switch 1 3

count

Output

2

3

2

Note

In the first sample the chronology of string *s* after some operations are fulfilled is as follows (the sought maximum subsequence is marked with bold):

- 47
- 74
- 74

- 747
- 447
- 447
- 774
- 774

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/21/2018 17:54:42 (d3).

Desktop version, switch to mobile version.

User lists

Name |
---|