P4939 Agent2

Background

The scorching summer has not ended yet, and none of the Agents want to go outside to do anything. Whenever ENLIGHTENED headquarters organizes an event, everyone says they are free, but when the event day arrives, they “gu gu gu” (cancel) one after another. Only the “never-cancel bird” `Lyn_king` waited under the sun for more than half an hour, and then even saw that the ENLIGHTENED operations staff also “gu gu gu”. Sure enough, “gu gu gu” is human nature.

Description

As an ENLIGHTENED operations commander, he naturally does not want to see this happen. So he secretly obtained the `event schedule` of those Agents who often “gu gu gu”, for the next $N$ days, and asked you to help organize it. During the organizing process, the ENLIGHTENED operations commander gave you $M$ commands. The commands are as follows. 1. Input $0,a,b$, which means that from day $a$ to day $b$, one Agent will “gu gu gu”. 2. Input $1$ $a$, which means that the ENLIGHTENED operations commander asks you, based on the current information, how many Agents will “gu gu gu” on day $a$. As someone who is also a “never-cancel bird”, you also want to punish those who often “gu gu gu”. Therefore, please help the ENLIGHTENED operations commander finish the organizing, and each time he asks, output the correct answer.

Input Format

The first line contains two integers $N, M$. The next $M$ lines each contain one command. The command format is given in the Description.

Output Format

For each query operation, output the answer to the query. Separate answers by newlines.

Explanation/Hint

For $20\%$ of the testdata, $N, M \leq 10$. For $40\%$ of the testdata, $N, M \leq 10^3$. For $60\%$ of the testdata, $N, M \leq 10^5$. For $100\%$ of the testdata, $1 \leq a, b \leq N \leq 10^7$, $M \leq 4 \times 10^5$. Translated by ChatGPT 5