题目描述
Problem Description
Given an undirected graph \( G \) with \( N \) vertices and \( M \) edges. The vertices of \( G \) are numbered from \( 1 \) to \( N \), and the \( i \)-th edge ( \( 1 \leq i \leq M \) ) connects vertices \( a_i \) and \( b_i \). \( G \) does not have self-loops or multiple edges.
You can repeatedly add edges between two vertices of \( G \), but the resulting graph must not have self-loops or multiple edges. Also, if vertices \( 1 \) and \( 2 \) are connected directly or indirectly, you will be struck by a voltage of \( 1000000007 \) volts. This must be avoided.
Under these conditions, what is the maximum number of edges you can add? Note that vertices \( 1 \) and \( 2 \) are not connected directly or indirectly initially.
Input Format
The input is given from the standard input in the following format:
\( N \) \( M \) \( a_1 \) \( b_1 \) \( : \) \( a_M \) \( b_M \)
Output Format
Output the maximum number of edges that can be added.
Sample Input and Output
Sample Input #1
4 1
1 3
Sample Output #1
2
Sample Input #2
2 0
Sample Output #2
0
Sample Input #3
9 6
1 4
1 8
2 5
3 6
4 8
5 7
Sample Output #3
12
Notes/Hints
Constraints
- \( 2 \leq N \leq 10^5 \)
- \( 0 \leq M \leq 10^5 \)
- \( 1 \leq a_i < b_i \leq N \)
- All pairs \( (a_i, b_i) \) are distinct.
- Vertices \( 1 \) and \( 2 \) are not connected directly or indirectly in \( G \).
Sample Explanation 1
As shown in the figure, you can add 2 edges. Adding more than 3 edges is not possible.
Sample Explanation 2
No edges can be added.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分