#include <bits/stdc++.h>
using namespace std;

int eu[2000],ev[2000],m;
long long n,dist[1000], INF=100000000000000001,ew[2000],ans;
bool inf[1000];
void bf(int s){
	fill(dist, dist+n,INF);
	dist[s]=0;bool up=true;
	for(int k=0;k<n-1;++k){
		for(int e=0;e<m;++e){
			if(dist[eu[e]-1]+ew[e]<dist[ev[e]-1] and dist[eu[e]-1]!=INF ){
				dist[ev[e]-1]=dist[eu[e]-1]+ew[e];
			}
			
		}
	}
	for(int k=0;k<n;k++){
		for(int e=0;e<m;++e){
			if(dist[eu[e]-1]+ew[e]<dist[ev[e]-1] and dist[eu[e]-1]!=INF){
				dist[ev[e]-1]=dist[eu[e]-1]+ew[e];
				inf[ev[e]-1]=true;
			}
			if(inf[eu[e]-1]){
				inf[ev[e]-1]=true;
			}
			
		}
	}
	
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>eu[i]>>ev[i]>>ew[i];
		ew[i]=-ew[i];
	}
	bf(0);
	if(inf[n-1]){
		cout<<"inf"<<endl;
	}else{
		cout<<-dist[n-1]<<endl;
	}
}