#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16]={0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
struct graph{
  int N, **edge, *es;
  void setDirectEdge(int N__, int M, int A[], int B[], void **mem = &wmem){
    int i;
    N = N__;
    walloc1d(&es, N, mem);
    walloc1d(&edge, N, mem);
    walloc1d(&edge[0], M, mem);
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      es[A[i]]++;
    }
    for(i=0;i<(N);i++){
      walloc1d(&edge[i], es[i], mem);
    }
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      edge[A[i]][es[A[i]]++] = B[i];
    }
  }
}
;
template<class T> struct wgraph{
  T **cost;
  graph g;
  int N, **edge, *es;
  void setDirectEdge(int N__, int M, int A[], int B[], T C[], void **mem = &wmem){
    int i;
    N = N__;
    walloc1d(&es, N, mem);
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      es[A[i]]++;
    }
    walloc1d(&edge, N, mem);
    for(i=0;i<(N);i++){
      walloc1d(&edge[i], es[i], mem);
    }
    walloc1d(&cost, N, mem);
    for(i=0;i<(N);i++){
      walloc1d(&cost[i], es[i], mem);
    }
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      edge[A[i]][es[A[i]]] = B[i];
      cost[A[i]][es[A[i]]++] = C[i];
    }
    g.N = N;
    g.es = es;
    g.edge = edge;
  }
  template<class S> void BellmanFord(int root, S res[], S unreachable = -1, S minusInf = -2, int step = -1, void *mem = wmem){
    S *arr;
    int KL2GvlyY, i, *inf, j, k, *q, qe, qs, t;
    walloc1d(&q, N, &mem);
    walloc1d(&inf, N, &mem);
    walloc1d(&arr, N, &mem);
    for(i=0;i<(N);i++){
      inf[i] = 0;
    }
    for(i=0;i<(N);i++){
      res[i] = arr[i] = std::numeric_limits<S>::max();
    }
    res[root] = arr[root] = 0;
    t = step;
    if(t==-1){
      t = N;
    }
    for(KL2GvlyY=0;KL2GvlyY<(t);KL2GvlyY++){
      for(i=0;i<(N);i++){
        if(res[i] != std::numeric_limits<S>::max()){
          for(j=0;j<(es[i]);j++){
            chmin(arr[edge[i][j]], res[i] + cost[i][j]);
          }
        }
      }
      for(i=0;i<(N);i++){
        res[i] = arr[i];
      }
    }
    if(step != -1){
      for(i=0;i<(N);i++){
        if(res[i]==std::numeric_limits<S>::max()){
          res[i] = unreachable;
        }
      }
      return;
    }
    for(i=0;i<(N);i++){
      if(res[i] != std::numeric_limits<S>::max()){
        for(j=0;j<(es[i]);j++){
          k = edge[i][j];
          if(arr[k] > res[i] + cost[i][j]){
            inf[k] = 1;
          }
        }
      }
    }
    qs = qe = 0;
    for(i=0;i<(N);i++){
      if(inf[i]){
        q[qe++] = i;
      }
    }
    while(qs < qe){
      i = q[qs++];
      for(j=0;j<(es[i]);j++){
        k = edge[i][j];
        if(inf[k]==0){
          inf[k] = 1;
          q[qe++] = k;
        }
      }
    }
    for(i=0;i<(N);i++){
      if(res[i]==std::numeric_limits<S>::max()){
        res[i] = unreachable;
      }
    }
    for(i=0;i<(N);i++){
      if(inf[i]==1){
        res[i] = minusInf;
      }
    }
  }
}
;
char memarr[96000000];
int N;
int M;
int A[2000];
int B[2000];
long long C[2000];
long long dist[1000];
int main(){
  int i;
  wgraph<long long> g;
  wmem = memarr;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(M);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
      rd(C[Lj4PdHRW]);
    }
  }
  for(i=0;i<(M);i++){
    C[i] = -C[i];
  }
  g.setDirectEdge(N, M, A, B, C);
  g.BellmanFord(0, dist, -1LL, -4611686016279904256LL);
  if(dist[N-1]==-4611686016279904256LL){
    wt_L("inf");
    wt_L('\n');
  }
  else{
    wt_L(-dist[N-1]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// int N, M, A[2000], B[2000]; ll C[2000];
// ll dist[1000];
// {
//   wgraph<ll> g;
//   rd(N,M,(A--,B--,C)(M));
//   rep(i,M) C[i] = -C[i];
//   g.setDirectEdge(N, M, A, B, C);
//   g.BellmanFord(0, dist, -1LL, -ll_inf);
//   wt( if[dist[N-1]==-ll_inf, "inf", -dist[N-1]] );
// }


Measured memory_bytes: 384