Transfer of debts
Imagine that there is a group of three friends: , and . owes rubles and owes rubles. The total sum of the debts is rubles. You can see that the debts are not organized in a very optimal manner. Let's rearrange them like that: assume that owes rubles and doesn't owe anything to anybody. The debts still mean the same, but the total sum of the debts now equals rubles.
This task is a generalization of a described example. Imagine that your group of friends has people, and you know the debts between the people. Optimize the given debts without changing their meaning. In other words, finally for each friend the difference between the total money he should give and the total money he should take must be the same. Print the minimum sum of all debts in the optimal rearrangement of the debts. See the notes to the test samples to better understand the problem.
Input
The first line contains two integers and . The next lines contain the debts. The -th line contains three integers , which mean that person owes person rubles.
Assume that the people are numbered by integers from to .
It is guaranteed that the same pair of people occurs at most once in the input. The input doesn't simultaneously contain pair of people and pair of people .
Output
Print a single integer — the minimum sum of debts in the optimal rearrangement.
Examples
In the first sample, you can assume that person number owes rubles to person number , ruble to person number and ruble to person number . He doesn't owe anybody else anything. In the end, the total debt equals .
In the second sample, there are no debts.
In the third sample, you can annul all the debts.