Under construction

Still being built. Things may change

Spreading a Virus in K512

Interview

Time limit2sMemory limit512 MB

Summary
Process infect and cure queries on N computers, and print how many computers are uninfected for each count query.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

K512 is busy preparing for the K512 Cup, which is held tomorrow. K512 has NN computers in total, numbered from 11 to NN.

Seunghyeong, who likes pranks, plans to spread a virus to the PCs in K512 and ruin the K512 Cup. Geunsu notices the plan and tries to cure the PCs so that they return to an uninfected state. Initially, every computer is uninfected. Given the numbers of the computers that Seunghyeong infects and that Geunsu cures, find the number of uninfected PCs in K512.

Input

The first line contains the number of computers N(1≤N≤2×105)N(1 \le N \le 2 \times 10^5) and the number of queries Q(1≤Q≤2×105)Q(1 \le Q \le 2 \times 10^5). Each of the next QQ lines contains one of the following queries.

  • 11 xx: Seunghyeong infects computer xx. He may infect a computer that is already infected, and nothing changes in that case. (1≤x≤N)(1 \le x \le N)
  • 22 xx: Geunsu cures computer xx, making it uninfected. He may cure a computer that is already uninfected, and nothing changes in that case. (1≤x≤N)(1 \le x \le N)
  • 33: Print the current number of uninfected computers in K512.

Output

For each query of type 33, print the answer on its own line. There is at least one query of type 33.

Hint

If input and output are slow, reading or printing many lines can cause a time limit error, so the following methods are recommended for each language.

  • C++: If you use cin/cout, put the following two lines at the start of main and print a newline character (\n) instead of endl. After doing this, you must not use C I/O such as scanf/printf/puts/getchar/putchar.

    • cin.tie(nullptr);
    • sync_with_stdio(false);
  • Python: Use the following instead of input.

    • sys.stdin.readline.rstrip()
  • Java, Kotlin: Use BufferedReader and BufferedWriter instead of Scanner and System.out.println. Call BufferedWriter.flush only once, before the program exits.

Examples1

  1. Example 1

    Input
    10 10
    1 3
    1 6
    1 3
    3
    2 3
    2 7
    1 7
    3
    1 9
    3
    
    Expected output
    8
    8
    7