#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef struct edge{
  int from, to; long cost;
  edge(int f, int t, long c){
    from = f; to = t; cost = c;
  }
}edge;

int main(){
  int n, m; cin >> n >> m;
  vector<edge> e;
  rep(i, m){
    int a, b; long c; cin >> a >> b >> c;
    e.push_back(edge(a-1, b-1, c));
  }
  long d[n];
  rep(i, n) d[i] = -LONG_MAX;
  d[0] = 0;
  rep(i, 2*n)rep(j, m){
    if(d[e[j].from] == -LONG_MAX) continue;
    if(d[e[j].to] < d[e[j].from] + e[j].cost){
      d[e[j].to] = d[e[j].from] + e[j].cost;
      if(i >= n-1 && e[j].to == n-1){
        cout << "inf" << endl;
        return 0;
      }
    }
  }
  cout << d[n-1] << endl;
}