#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


struct Edge{
    ll from, to, cost;
    Edge(ll _from=0, ll _to=0, ll _cost=0) :from(_from), to(_to), cost(_cost) {}
};

struct BellmanFord{
    ll const inf = 1LL<<60;
    int V; // number of vertix
    vector<ll> d;
    vector<bool> negative;
    vector<Edge> edges;

    // コンストラクタ
    BellmanFord(int _V) : V(_V) {
        d.resize(V, inf);
        negative.resize(V, false);
    }

    void add_edge(ll from, ll to, ll cost) { edges.push_back(Edge{from, to, cost}); }

    // 最短距離の計算と負閉路検出を同時にやる
    void calcMinDistFrom(int s){
        d[s] = 0;
        rep(loop, V){
            rep(i, (int)edges.size()){
                if(d[edges[i].from] == inf) continue;
                if(d[edges[i].to] > d[edges[i].from] + edges[i].cost) { d[edges[i].to] = d[edges[i].from] + edges[i].cost; };
            }
        }

        rep(loop, 2*V){
            rep(i, (int)edges.size()){
                if(d[edges[i].from] == inf) continue;
                if(d[edges[i].to] > d[edges[i].from] + edges[i].cost) {
                    d[edges[i].to] = d[edges[i].from] + edges[i].cost;
                    negative[edges[i].to] = true;
                }
                if(negative[edges[i].from]) negative[edges[i].to] = true;
            }
        }
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    BellmanFord bell(N);
    rep(i, M){
        ll a, b, c; cin >> a >> b >> c; --a; --b;
        bell.add_edge(a, b, -c);
    }
    bell.calcMinDistFrom(0);

    ll ans = bell.d[N-1];
    cout << (bell.negative[N-1]?  "inf":to_string(-ans)) << endl;
    
    return 0;
}

Measured memory_bytes: 384