#include <iostream>
#include <cstdio>
#define N 1005
#define M 2005
using namespace std;

typedef long long ll;
ll n, m, a[M], b[M], c[M], d[N];
bool v = 1;
int main()
{
	ll i, j, t;
	cin >> n >> m;
	for (i = 0; i < m; i++) scanf("%lld %lld %lld", &a[i], &b[i], &c[i]);
	for (i = 2; i <= n; i++) d[i] = -1e18;
	for (i = 0; i < n - 1 && v; i++) {
		v = 0;
		for (j = 0; j < m; j++) {
			if (d[b[j]] < d[a[j]] + c[j]) v = 1, d[b[j]] = d[a[j]] + c[j];
		}
	}
	if (v) {
		t = d[n];
		for (i = 0; i < m; i++) {
			if (d[b[i]] < d[a[i]] + c[i]) d[b[i]] = d[a[i]] + c[i];
		}
		if (t != d[n]) {cout << "inf"; return 0;}
	}
    cout << d[n];
    return 0;
}