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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(void) {

	ll N,M;
	cin >> N >> M;

	vector<ll> a(M), b(M), c(M);
	REP(i, M) {
		cin >> a[i] >> b[i] >> c[i];
	}

	ll d[1010];
	d[0] = 0;
	FOR(i, 1, 1010) d[i] = -(1e17);

	ll count = 0;
	ll temp;

	while (count < N*2+1) {

		if (count == N) {
			temp = d[N - 1];
		}

		FOR(i, 0, M){
			d[b[i]-1] = max(d[b[i]-1], d[a[i]-1]+c[i]);
		}

		if (count == (N*2)) {
			break;
		}
		count++;
	}

	if (d[N - 1] > temp) {
		cout << "inf" << endl;
	}
	else {
		cout << d[N - 1] << endl;
	}


	return 0;
}