eolymp
bolt
Try our new interface for solving problems
Problems

Segments

Segments

Consider a real axis and segments on it. You are to write a program that processes queries of two kinds.

  • Query '**+ L R**' adds a segment from point L to point R. You program should print the number of segments that are (non-strictly) inside the new one.

  • Query '**- L R**' removes one segment from point L to point R. If there is no such segment, ignore this query.

You may assume that no more than 1000 segments will present on the axis simultaneously.

Input

Each line contains one query. Query can be in the form '**- L R**' or '**+ L R**' where L and R are integers (-109L < R109). There will be no more than 250 000 queries.

Output

Print to the output one line for each '**+ L R**' query, containing the number of segments inside the added segment.

Time limit 1 second
Memory limit 256 MiB
Input example #1
+ 1 2
+ 1 2
+ 0 3
- 1 2
+ 1 2
Output example #1
0
1
2
1
Source 2007 Петрозаводск, Saratov for Karelia with love, Январь 28, Задача D