// finish date: 2018/07/11
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


template<typename T>
bool BellmanFord(int s, int V, vector<vector<pair<T, int>>> edge, vector<T> &dist) {
    if (typeid(T) == typeid(int)) dist = vector<T>(V, INF);
    else dist = vector<T>(V, LONG_LONG_MAX / 4);
    dist[s] = 0;
    bool ischange;
    int cnt = 0;
    vector<bool> used;
//
//    rep(i, V) {
//        rep(j, M) {
//            if (dist[i] <)
//        }
//    }


    do {
        used = vector<bool>(V, false);
        queue<pair<T, int>> que;
        cnt++;
        ischange = false;
        for (pair<T, int> e:edge[s]) {
            que.push(make_pair(dist[s] + e.first, e.second));
        }
        used[s] = true;
        while (!que.empty()) {
            T d;
            int t;
            tie(d, t) = que.front();
            que.pop();
            if (d < dist[t]) {
                dist[t] = d;
                ischange = true;
            }
            if (used[t]) continue;
            for (pair<T, int> e: edge[t]) {
                que.push(make_pair(dist[t] + e.first, e.second));
            }
            used[t] = true;
        }
    } while (ischange && cnt <= V);
    return !ischange;
}


template<typename T>
void BellmanFord2(int s, int V, int E, vector<int> from, vector<int> to, vector<T> d, vector<T> &dist,
                  vector<bool> &negative) {
    if (typeid(T) == typeid(int)) dist = vector<T>(V, INF);
    else dist = vector<T>(V, LONG_LONG_MAX / 4);
    dist[s] = 0;
    bool ischange;
    int cnt = 0;
    vector<bool> used;

    rep(i, V - 1) {
        ischange = false;
        rep(j, E) {
            if (dist[from[j]] + d[j] < dist[to[j]]) {
                ischange = true;
                dist[to[j]] = dist[from[j]] + d[j];
            }
        }
        if (!ischange) break;
    }

    negative = vector<bool>(V, false);

    rep(i, V) {
        ischange = false;
        rep(j, E) {
            if (dist[from[j]] + d[j] < dist[to[j]]) {
                ischange = true;
                dist[to[j]] = dist[from[j]] + d[j];
                negative[to[j]] = true;
            }
        }
        if (!ischange) break;
    }
}


int main() {
    int N, M;
    cin >> N >> M;

    vi a(M), b(M);
    vl c(M);
    rep(i, M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        c[i] *= -1;
    }
    vl dist;
    vb negative;
    BellmanFord2(0, N, M, a, b, c, dist,negative);
    if(!negative[N-1]){
        cout << -dist[N - 1] << endl;
    } else {
        cout << "inf" << endl;
    }

//    vector<vector<pair<ll, int>>> edge(N);
//    rep(i, M) {
//        int a, b, c;
//        cin >> a >> b >> c;
//        a--;
//        b--;
//        c *= -1;
//        edge[a].push_back(make_pair(c, b));
//    }
//    vl dist;
//    if (BellmanFord(0, N, edge, dist)) {
//        cout << -dist[N - 1] << endl;
//    } else {
//        cout << "inf" << endl;
//    }

    return 0;
}



Measured memory_bytes: 256