last-task-1
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

John is taking a white paper and starting noted down the random numbers in ascending order in the list. John is briliant in mathematics so he tries to find out how many of these numbers have P as a divisor.So help him to calculate the numbers which is divisible by P.

Assume that number are taking by John is integers only.

Input Format 
The first line of input contains T, the number of queries.

The following T lines contain the queries.Each query is either type 1 or 2.  

Queries is defined in following manner :- 
1.) + A. This query adds the integer A at the last of the list. It is given that numbers   are always added in ascending order.
2.) ? X Y P. For every query of this type, you need to output the number of integers A currently in the list such that A is at least X, at most Y and has P as its divisor.   

Output Format

For each type 2 query, output a line containing the number of integers A available on the list such that A is at least X, at most Y and has P as its divisor.

Constraints

1 ≤ T ≤ 3*10^5   
1 ≤ X ≤ Y ≤ 3*10^5   
1 ≤ P ≤ 3*10^5   
1 ≤ A ≤ 3*10^5 
The numbers are always added in ascending order in the list.

SAMPLE INPUT
10
+ 1
+ 2
+ 4
+ 7
? 2 8 2
+ 8
? 2 8 4
+ 11
+ 23
? 1 300000 9

SAMPLE OUTPUT
2
2
0

Explanation

During the first type 2 query, the list contains [1, 2, 4, 7]. There is only one element in this list which is at least X=2, at most Y=8 and has 2 as its factor - this is the element 2 and 4.

During the second type 2 query, the list contains [1, 2, 4, 7, 8]. There are only two elements in this list which are at least A=2, at most B=8 and have 4 as its factor - these are the elements 4 and 8.

During the third ASK query, the list contains [1, 2, 4, 7, 8, 11, 23]. There are no elements in this list which are at least A=1, at most B=300000 and have 9 as its factor.