401826: GYM100534 I Coin Robbery

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Coin Robberytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Steve is a prominent coin collector and John is a professional thief, but Steve is not aware of this fact. They make friends and someday Steve asks John to help him move his coins to some other place. At the middle of the movement John plans a robbery and takes all Steve's coins. He has planned to go to airport and run away to Somalia as soon as possible. This is the live conversation between Police station and Police officer. Police Station: We have found John's flight number, he is a mother lover, he wants to dedicate these coins to his mother in Somalia. he will use airport to run away to Somalia. Police Officer: So ask airport security to arrest him. Police Station: Right now we have no authority in airport. We have to do something in the city to arrest him out of airport or delay his arrival to the airport so he will miss his flight. John is smart, he has planned to arrive in airport and catch his plane with no delay in between. Police Officer: We have some police officers in all intersections, we need to inform them to make block some intersections. We can not block starting intersection nor ending intersection (airport). Intersections are numbered from 0 to n - 1. John starts his path from intersection 0 (John's starting intersection is intersection [number] 0) and airport is in intersection [number] n - 1.

Now it's your turn, inform minimum number of police officers at intersections so that we can arrest John in one of the intersections or we can delay his arrival to airport so that he will miss his flight.

Input

First line of input contains two integers, n and m, the number of intersections and the number of streets, correspondingly. Each of the next m lines contains a description of a bidirectional street, two ends of the street and the length of the street. (2 ≤ n ≤ 100) (1 ≤ m ≤ 10000) (1 ≤ length of each street ≤ 100)

Output

If it's impossible to block John from entering airport, print IMPOSSIBLE, otherwise print the minimum number of intersections we need to block.

ExamplesInput
3 3
0 1 1
1 2 1
0 2 3
Output
1

加入题单

算法标签: