Ivan Operations
Ivan, a smart kid (like his brother Joshua), is playing with a long string S consisting of lowercase characters. He can do the following operations:
- S i j c: change the characters in the range [i, j] to the value c
- R i j: reverse the substring starting from position i to position j
- C i j c: count the number of characters with value c in the range [i, j]
All indexes are 1-based.
Especificación de entrada
Input starts with a line containing the string S of length between 1 and 100,000. All characters will be lowercase letters. The next line contains an integer , the number of operations to be performed. Each of the next Q lines consists of an operation in the format shown above. You may assume that the positions are valid (1 <= i <= j <= length of S) and the character c is a lowercase letter.
Especificación de salida
For each operation of type C, output a line with the number of characters c present in the substring i to j at that point in time.
Ejemplo de entrada
abcccxxxyz
7
C 2 6 b
S 1 4 b
S 6 7 b
C 2 6 b
C 6 7 x
R 5 10
C 6 7 x
Ejemplo de salida
1
4
0
1
Comments