#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
// void fill(ll n, ll a[n], ll value){ rep(i,0,n) a[i] = value; }
void cin(ll *n){ scanf("%lld",&(*n)); }
void cin2(ll *a, ll *b){ scanf("%lld%lld",&(*a),&(*b)); }
void cin3(ll *a, ll *b, ll *c){ scanf("%lld%lld%lld",&(*a),&(*b),&(*c)); }
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

/*-----------------------------------------------------------------------*/
ll ans[1141];
typedef struct{
    ll from;
    ll to;
    ll cost;
}graph_info;
graph_info edge[11412];
//https://qiita.com/wakimiko/items/69b86627bea0e8fe29d5
int BellmanFord(ll start, ll vert , ll e){
    ll cnt=0,update=1;
    rep(i,0,vert) ans[i]=INF;
    ans[start] = 0;

    while(update){
        update = 0;
        if(cnt++>vert) return 1;
        rep(i,0,e){
            if( ans[edge[i].from]!=INF && ans[ edge[i].to ] > ans[edge[i].from] + edge[i].cost ){
                if(cnt>vert && edge[i].to==vert-1 ) return 0;
                //     if(edge[i].to==vert-1) return 0;
                // }
                update=1;
                ans[ edge[i].to ] = ans[edge[i].from] + edge[i].cost;
            }
        }
        // cnt++;
    }
    return 1;
}

/*--------------------------------------------------------------------------------------------*/

int main(void){
    // char ;
    ll n,m;
    // ll ans=0;
    // cin(&n);
    cin2(&n,&m);
    // ll [n];
    ll a,b,c;
    rep(i,0,m){
        cin3(&a,&b,&c);
        edge[i].from = a-1;
        edge[i].to = b-1;
        edge[i].cost = -c;
    }
    if( BellmanFord(0,n,m) == 0 ){
        printf("inf\n");
        return 0;
    }
    // rep(i,0,n) printf("%lld\n",ans[i]);
    printf("%lld\n",-ans[n-1]);
    return 0;
}


Measured memory_bytes: 256