Little Qiang is watching the night sky after completing his math homework. After staring boringly at the sky for a while, he observes that actually many stars are lying on identical lines, so that a few number of parallel lines are suffice to cover all the stars in the sky. Being passionate about both astronomy and math, he decides to find out the minimum number of parallel lines to achieve the full coverage of stars. Moreover, the stars appear and disappear from time to time, making the problem more interesting.
Specifically, we assume that the stars are numbered from 1 to N. Initially, there are no stars in the sky. Then the sky will be refreshed for M rounds. For each round, one star will appear/disappear, and Little Qiang will compute again the result. Note that the same star could appear/disappear for more than once.
Unfortunately, Little Qiang has Trypophobia such that he cannot insist looking at the sky for a long period to finish the entire task. What a pity! Can you help him?
(The figure shows a concrete snapshot of the sky, where 3 parallel lines (the blue lines) are sufficed to cover all the 6 stars.)