Flow

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

문제

One of Pang's research interests is the maximum flow problem. 

A directed graph GG with nn vertices is universe if the following condition is satisfied:

  • GG is the union of kk vertex-independent simple paths from vertex 11 to vertex nn of the same length.

A set of paths is vertex-independent if they do not have any internal vertex in common. 

A vertex in a path is called internal if it is not an endpoint of that path.

A path is simple if its vertices are distinct.

Let GG be a universe graph with nn vertices and mm edges. Each edge has a non-negative integral capacity. You are allowed to perform the following operation any (including 00) times to make the maximum flow from vertex 11 to vertex nn as large as possible:\\

Let ee be an edge with positive capacity. Reduce the capacity of ee by 11 and increase the capacity of another edge by 11.\\

Pang wants to know what is the minimum number of operations to achieve it?

입력

The first line contains two integers nn and mm (2n100000,1m2000002\leq n\leq 100000, 1\leq m \leq 200000).

Each of the next mm lines contains three integers x,yx, y and zz, denoting an edge from xx to yy with capacity zz (1x,yn1 \leq x, y \leq n, 0z10000000000\le z\le 1000000000).

It's guaranteed that the input is a universeuniverse graph without multiple edges and self-loops.

출력

Output a single integer --- the minimum number of operations.