#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>

#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>

#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;
#include<cstdio>
#include<cstring>
//从顶点frome指向顶点to的权值为cost的边
const int MAX_E=2005;
const int MAX_V=1005;
const int INF=1<<30;
struct edge
{
    int from,to;
    ll cost;
};
edge es[MAX_E];//边
ll d[MAX_V];//最短距离
int V,E;//顶点数，边数
//求解从顶点s出发到所有点的最短距离
bool shortest_path(int s)
{
    for(int i=1;i<=V;i++)
        d[i]=200000000000000000;
    d[s]=0;
    int cnt=0;
    while(true)
    {
        bool update=false;
        for(int i=0;i<E;i++)
        {
            edge e=es[i];
            if(d[e.from]!=200000000000000000&&d[e.to]>d[e.from]+e.cost)
            {
                d[e.to]=d[e.from]+e.cost;
                if(cnt==V-1)
                    return true;
                update=true;
            }
        }
        if(!update)
            break;
        cnt++;
    }
    return false;
}
//如果返回true则存在负圈
bool find_negative_loop()
{
    memset(d,0,sizeof(d));
    for(int i=0;i<V;i++)
    {
        for(int j=0;j<E;j++)
        {
            edge e=es[j];
            if(d[e.to]<d[e.from]+e.cost)
            {
                d[e.to]=d[e.from]+e.cost;
                //如果第n次仍然更新了，则存在负圈
                if(i==V-1)
                    return true;
            }
        }
    }
    return false;
}
int main()
{
    scanf("%d%d",&V,&E);
    int u,v;
    ll val;
    for(int i=0;i<E;i++)
    {
        scanf("%d%d%lld",&u,&v,&val);
        es[i].from=v;
        es[i].to=u;
        es[i].cost=val*-1ll;
    }

    if(shortest_path(V) == false){
        printf("%lld\n",d[1]*-1ll);
    }else{
        printf("inf\n");
    }
    return 0;
}


Measured memory_bytes: 256