Mountain Hikes

No attempts yetTime limit1sMemory limit128 MB

Problem

Bajtłomiej is a mountain hiking enthusiast. This year he is spending his vacation in Low Byteland, a beautiful mountain region in the south of Byteland. Every morning he sets out on a hike from one of the shelters and walks a route that brings him back to the very same shelter by the evening (each day he may pick a different starting shelter). Bajtłomiej is a picky hiker, though: during a single day he never passes the same shelter twice. In other words, each day's route is a single simple cycle (a closed walk that returns to its start without revisiting any shelter).

After finishing each hike, he picks the most boring trail among those he walked that day (if several trails are equally boring, he picks any one of them) and erases it from his map. From that moment on he never uses that trail again. He keeps erasing trails until he can no longer plan a hike that meets his requirements (that is, until the remaining trails can no longer form any simple cycle), at which point he packs his backpack and goes home.

Write a program that reads the description of the trails in Low Byteland from standard input, computes how many hikes Bajtłomiej goes on, and writes the answer to standard output.

Input

The first line contains two integers nn and mm (1n1000001 \le n \le 100000, 0m3000000 \le m \le 300000): the number of shelters and the number of trails in Low Byteland, respectively.

Each of the next mm lines describes one trail. The ii-th of them describes the trail numbered ii and contains three integers aa, bb, and cc separated by spaces (1a,bn1 \le a, b \le n, aba \ne b, 1c50001 \le c \le 5000). They mean that shelters aa and bb are joined by a trail whose interest coefficient is cc (the lower the coefficient, the more boring the trail). There is at most one trail between any pair of shelters.

Output

Print a single integer: the total number of hikes Bajtłomiej goes on (equivalently, the number of trails he erases from his map).