// Slower C++ solution:
#include<iostream>

#include<vector>

#include<queue>

#include<stack>

#include<string>

#include<cmath>

#include<algorithm>

#include<bitset>

#include<map>

#include<functional>

#include<set>



#pragma region

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)

#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)

#define ALL(x) x.begin(),x.end()

#define RALL(x) x.rbegin(),x.rend()

#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;

#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);

#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);

#define INF 111111111111111111

#define MOD 1000000007

#define pb push_back

#define F first

#define S second

typedef long long int ll;

typedef long double ld;

typedef vector<ll> vll;

typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;

string s;

bool flag, ok;

ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };

ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };

#pragma endregion

#define MAX 111111





vector<pll> edge[MAX];

ll d[MAX], d2[MAX];



bool Bellmanford(int start, ll x) {

  FOR(i, 1, n + 1) d[i] = INF;

  d[start] = 0;

  while (true) {

	bool flag = false;

	FOR(i, 1, n + 1) {

	  FOR(j, 0, edge[i].size()) {

		if (d[i] != INF && d[edge[i][j].F] > d[i] + edge[i][j].S) {

		  d[edge[i][j].F] = d[i] + edge[i][j].S;

		  flag = true;

		  if (cnt >= n * x) return true;

		}

	  }

	}

	if (!flag) break;

	cnt++;

  }

  return false;

}



int main(void) {

  ll a, b, c;

  cin >> n >> m;

  FOR(i, 0, m) {

	cin >> a >> b >> c;

	c = -c;

	edge[a].pb(pll(b, c));

  }



  Bellmanford(1,1);

  ans = -d[n];

  FOR(i, 1, n + 1) d2[i] = d[i];

  Bellmanford(1,3);



  if (d[n] != d2[n]) {

	cout << "inf" << endl;

  }

  else {

	cout << -d[n] << endl;

  }



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.7713471736844975x):
#include<iostream>

#include<vector>

#include<queue>

#include<stack>

#include<string>

#include<cmath>

#include<algorithm>

#include<bitset>

#include<map>

#include<functional>

#include<set>



#pragma region

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)

#define rep(i,n) FOR(i,0,n)

#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)

#define ALL(x) x.begin(),x.end()

#define RALL(x) x.rbegin(),x.rend()

#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;

#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);

#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);

#define scan(x) scanf("%lld",&x);

#define inf 5555555555555555555

#define mod 1000000007

#define pi 3.14159265358979323846

#define pb push_back

typedef long long int ll;

typedef vector<ll> vll;

typedef vector<vll> vvll;

typedef pair<ll, ll> pll;

typedef vector<pll> vpll;

typedef map<ll, ll> MAP;

typedef set<ll> SET;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;

string s;

bool ok, flag;

ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };

ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };

#pragma endregion

#define MAX 111111



struct Weighted_Graph {

  struct edge { ll node, cost; };

  vector<vector<edge>> e;



  void set(ll x) { e.resize(x + 1); }



  void add_edge(ll a, ll b, ll c) { e[a].pb(edge{ b,c }); }



  vll dijkstra(ll start) {

	priority_queue<pll, vector<pll>, greater<pll>> pq;

	ll u;

	pll p;

	vll dist(e.size(), inf);

	dist[start] = 0;

	pq.push(pll(0, start));



	while (!pq.empty()) {

	  p = pq.top(); pq.pop();

	  u = p.second;

	  if (dist[u] < p.first) continue;

	  for (edge e1 : e[u]) {

		if (dist[e1.node] > dist[u] + e1.cost) {

		  dist[e1.node] = dist[u] + e1.cost;

		  pq.push(pll(dist[e1.node], e1.node));

		}

	  }

	}

	return dist;

  }



  void floyd(vvll &dist) {

	ll x = e.size();

	dist.resize(x);

	rep(i, x) dist[i].resize(x, inf);

	rep(i, x) dist[i][i] = 0;

	rep(i, x) rep(j, e[i].size()) dist[i][e[i][j].node] = e[i][j].cost;

	rep(k, x) {

	  rep(i, x) {

		if (dist[i][k] == inf) continue;

		rep(j, x) {

		  if (dist[k][j] == inf) continue;

		  dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

		}

	  }

	}

  }



  bool bellmanford(ll start, vll &dist) {

	ll x = e.size(), cou = 0;

	if (dist.size() == 0) {

	  dist.resize(x, inf);

	  dist[start] = 0;

	}

	while (1) {

	  bool cycle = false;

	  rep(i, n) {

		rep(j, e[i].size()) {

		  if (dist[i] != inf && dist[e[i][j].node] > dist[i] + e[i][j].cost) {

			dist[e[i][j].node] = dist[i] + e[i][j].cost;

			cycle = true;

			if (cou == x) return cycle;

		  }

		}

	  }

	  cou++;

	  if (!cycle) break;

	}

	return false;

  }



};



int main(void) {

  Weighted_Graph wg;

  vll d;

  ll a, b, c;

  cin >> n >> m;

  wg.set(n);

  FOR(i, 0, m) {

	cin >> a >> b >> c;

	a--; b--;

	wg.add_edge(a, b, -c);

  }



  wg.bellmanford(0, d);

  tmp = d[n - 1];

  wg.bellmanford(0, d);

  ans = d[n - 1];

  if (tmp != ans) {

	cout << "inf" << endl;

  }

  else {

	cout << -ans << endl;

  }



  return 0;

}