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

int n, m;
typedef pair<int, int> P;
vector<P> g[1010];
long long int dist[1010];
long long int inf = 1e15;

bool BellmanFord(){
	for(int i=1; i<n; ++i)
		dist[i] = inf;
	for(int i=0; i<2*n; ++i){
		for(int j=0; j<n; ++j){
			for(int k=0; k<g[j].size(); ++k){
				if(dist[j] != inf && dist[g[j][k].second] > dist[j] + g[j][k].first){
					dist[g[j][k].second] = dist[j] + g[j][k].first;
					if(i >= n-1 && g[j][k].second == n-1)
						return true;
				}
			}
		}
	}
	return false;
}

int main(){
	cin >> n >> m;
	for(int i=0; i<m; ++i){
		int a, b, c;
		cin >> a >> b >> c;
		g[a-1].push_back(P(-c, b-1));
	}
	if(BellmanFord()) cout << "inf" << endl;
	else cout << -dist[n-1] << endl;
/*	for(int i=0; i<n; ++i)
		cout << dist[i] << endl;
*/
}