D. Dream Team
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Summer training is coming soon, and in order to achieve good results in the upcoming contests, everyone wants to find their favorite teammates to form their own dream team!

There are $$$3n$$$ students in the training team with corresponding numbers $$$1$$$ to $$$3n$$$ , and they will form $$$n$$$ teams, each consisting of $$$3$$$ students .

It is now known that there are $$$m$$$ pairs of students $$$(x_i, y_i)$$$ who are directly familiar with each other (i.e. $$$x_i$$$ is directly familiar with $$$y_i$$$ , and $$$y_i$$$ is directly familiar with $$$x_i$$$ ) .

Friends of friends are friends. We define that student $$$a$$$ is familiar with student $$$b$$$ if one of the following conditions is met:

1. $$$a$$$ is directly familiar with $$$b$$$ , or

2. There exists a series of students $$$x_1,x_2,\dots, x_k\ (k \gt 0)$$$ satisfies:

  • $$$a$$$ is directly familiar with $$$x_1$$$
  • for all $$$1 \le i \lt k$$$ , $$$x_i$$$ is directly familiar with $$$x_{i+1}$$$
  • $$$x_k$$$ is directly familiar with $$$b$$$

As a retired contestant, Colin clearly knows that it is important for teammates to be familiar with each other. We define a student's anxiety level as the number of students in his team that he is not familiar with (of course everyone is familiar with himself) . Now Colin wants you to find a plan satisfies: divide all $$$3n$$$ students into $$$n$$$ teams, and each student is in exactly one team, and each team has exactly $$$3$$$ students, and minimize the sum of anxiety level of all $$$3n$$$ students.

You only need to tell Colin the minimum sum of anxiety level of all $$$3n$$$ students.

Input

The first line contains two integers $$$n, m\ (1\le n\le 10^6,1\le m\le 2\times 10^5)$$$ , representing there are $$$3n$$$ students and $$$m$$$ pairs of students directly familiar with each other.

For the following $$$m$$$ lines, each line contains two integers $$$x_i,y_i\ (1\le x_i,y_i\le 3\times n, x_i\ne y_i)$$$ , representing $$$x_i, y_i$$$ are directly familiar with each other.

Output

Output one integer: the minimum possible sum of the anxiety levels of all $$$3n$$$ students.

Example
Input
3 5
1 2
1 3
4 5
4 6
7 8
Output
4