A social app processes m friend-link requests over n users (numbered 1 through n), in the given order. A request joining users u and v is called redundant if, at the moment it is processed, u and v are already in the same friend circle — that is, they are already connected directly or through a chain of earlier links (a request that links a user to themselves is also redundant). A non-redundant request adds a new link; a redundant request changes nothing.
Count how many of the m requests are redundant.
Input format
- Line 1: two integers
nandm. - Next
mlines: two integersuandv(1-indexed), the request to linkuandv, in processing order.
Output format
A single integer: the number of redundant requests.
Constraints
- 1 <= n <= 100000
- 0 <= m <= 200000
- 1 <= u, v <= n