#include <stdio.h>
#include <map>
#include <vector>
struct edge {long long from, to, cost;};

edge es[20000];
long long d[1100];
int over[1252];
int n,m;

using namespace std;
int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    long long a,b,c;
    scanf("%lld%lld%lld", &a,&b,&c);
    es[i].from = a-1;
    es[i].to = b-1;
    es[i].cost =  c;
  }
  for(int i = 0; i < n; i++)d[i] = -10000000000000;
  d[0] = 0;
  for(int k=0;k<=2*n;k++){
    for(int i=0;i<m;i++){
      if(d[es[i].from] != -10000000000000 && d[es[i].to] < d[es[i].from] + es[i].cost){
        d[es[i].to] = d[es[i].from] + es[i].cost;
        if(k == 2*n){
          over[es[i].to] = 1;
        }
      }
    }
  }
  if(over[n-1])printf("inf\n");
  else printf("%lld\n", d[n-1]);
}
