#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

Peanut is the mayor of a new city, Silvermill. Silvermill has *N* towns, numbered 0 to *N*-1, which are completely disconnected from one another. He hires a contractor, who gives him a list of *E* proposed roads, with the *i*th road proposed to connect towns *A _{i}* and

*B*directly, at the cost of

_{i}*C*dollars.

_{i}Peanut wishes to build a subset of roads proposed by the contractor, such that between any two towns, there exists a direct or indirect path between them. Help Peanut find the minimum possible cost of achieving this. It is guaranteed that there exists at least one subset of chosen roads that would accomplish this goal.

## Input

The first line of input will contain two integers, *N* and *E*.

The next *E* lines of input will contain three integers each, *A _{i}*,

*B*and

_{i}*C*.

_{i}## Output

The output should contain exactly one integer, the minimum cost, in terms of dollars, that Peanut needs to spend to connect the towns of Silvermill to one another.

## Limits

1 ≤ N, E ≤ 10^{6.}

0 ≤ A_{i}, B_{i} < N.

1 ≤ C_{i} ≤ 10^{9}.

## Sample Input

4 6 0 1 2 1 2 1 2 3 1 3 0 1 0 2 3 1 3 5

## Sample Output

3

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 100 | 31 | 2s | 256MB | Minimum |

2 | 0 | 1 | 2s | 256MB | Minimum |

### Judge Compile Command

g++-8 ans.cpp -o newtown -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512