7412 - Illegal Action   

Description

You are a student in Dao Dan’s class. Someday, Dao Dan opens the file of the student’s grades to edit. The grades of the students are either failed or passed. He wants to adjust the grades fast. He calls ALAN to write a program, which provides 4 operations:

(a)    p x y: Let the student whose id is between [x, y] passed.

(b)   f x y : Let the student whose id is between [x, y] failed.

(c)    q x y : Count then number of passed student whose id is between [x, y].

(d)   r x y : Let the grades of the students whose id is between [x, y] reverse. (Passed<->Failed)

You want to help ALAN write the program. Maybe ALAN will like you to let you passed without telling Dao Dan.

 

Input

Each test case starts with a line containing two integers n(1<=n<=105)  and q(1<=q<=2*105)  indicating the number of the student and the number of events. Then one line contains a P-F string representing the original grade of the student. Following this are q lines, each containing one character c and two integers x, y. The first character c specifies the type of the event. For every event, x and y mean the interval you want to adjust(1<=x<=y<=n).

Output

For every type-(c) event, output the number of the passed student whose ID is between [x, y].

 

Sample Input  Download

Sample Output  Download

Tags




Discuss