#include<iostream>
#include<algorithm>
#include<limits>
#include<vector>
 
using namespace std;

// 増加し続けるループがあっても、頂点Nに到達できなければ関係ない

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, i;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	vector<int> c(m);
	for (i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
	}
	long long minnum = numeric_limits<long long>::min();
	vector<long long> score(n, minnum);
	score[0] = 0;
	long long ans;
	for (i = 0; i < 2*n; i++) {
		for (int j = 0; j < m; j++) {
			if (score[a[j]]>minnum && score[b[j]] < score[a[j]] + c[j]) {
				score[b[j]] = score[a[j]] + c[j];
			}
		}
		if (i == n) ans = score[n - 1];
		if (i == 2*n - 1 && ans == score[n - 1]) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << "inf" << endl;
	return 0;
}