Build the Graph

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

For an undirected graph GG with nn nodes and mm edges, we can define the distance dist(i,j)\textit{dist} (i, j) as the length of the shortest path between nodes ii and jj. The length of a path is equal to the number of edges in the path. If there is no path between ii and jj, we set dist(i,j)\textit{dist} (i, j) equal to nn.

Then, we can define w_Gw\_G, the weight of the graph GG, as _i=1n_j=1ndist(i,j)\sum\_{i = 1}^n \sum\_{j = 1}^n \text{dist} (i, j).

Now, given nn nodes and no edges initially, we will choose no more than mm pairs of nodes (i,j)(i, j) (iji \neq j) and add an edge between the respective nodes for every chosen pair. This way, we can get an undirected graph GG with nn nodes and no more than mm edges.

Your task is to find the minimal possible value of w_Gw\_G after such construction.

입력

The first line of the input contains two integers nn and mm (1n1061 \leq n \leq 10^6, 1m10121 \leq m \leq 10^{12}).

출력

Print a single line with a single integer: the minimum possible value of w_Gw\_G.

힌트

In the example, we can choose to add edges (1,2)(1, 2), (1,4)(1, 4), (2,4)(2, 4), (2,3)(2, 3) and (3,4)(3, 4).