import heapq INF=10**18 N,M=map(int,input().split()) assert 2<=N<=100 assert 1<=M<=100 G=[[]for i in range(N)] for i in range(M): A,B,C=map(int,input().split()) assert 1<=Ac+e[1]//p: dist[e[0]][p]=c+e[1]//p heapq.heappush(PQ,(c+e[1]//p,e[0],p)) print(min(dist[N-1]))