#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

template<typename T = ll, typename U = ll> class BellmanFord {
public:

    struct edge {
        T from, to;
        U cost;
    };

    ll V; //頂点数（なくてもよい）
    vector<edge> E;
    unordered_map<T, U> d;

    BellmanFord(ll V_num = 2010) : V(V_num) {
    }

    void calc(T s) {
        d.clear();
        rep(i, V + 1) d[i] = LINF;
        d[s] = U(0);
        while (1) {
            bool update = false;
            for (auto e : E) {
                //if (d.find(e.from) == d.end()) d[e.from] = LINF;
                //if (d.find(e.to) == d.end()) d[e.to] = LINF;
                if (d[e.from] != LINF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    update = true;
                }
            }
            if (!update) return;
        }
    }

    bool calc_and_find_negative_loop(T s, T g) {
        d.clear();
        map<T, U> negative;
        rep(i, V + 1) d[i] = LINF;
        d[s] = U(0);

        rep(i, V) {
            bool update = false;
            for (auto e : E) {
                //if (d.find(e.from) == d.end()) d[e.from] = LINF; (map使うときの初期化用)
                //if (d.find(e.to) == d.end()) d[e.to] = LINF;
                if (d[e.from] != LINF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    update = true;
                    if (i == V - 1) negative[e.from] = negative[e.to] = true;
                }
            }
            if (!update) return false;
        }
        return negative[g];
    }

    bool find_any_negative_loop() {
        map<T, U> d_;
        rep(i, V) for (auto e : E) {
            if (d_[e.to] > d_[e.from] + e.cost) {
                d_[e.to] = d_[e.from] + e.cost;
                if (i == V - 1) return true;
            }
        }
        return false;
    }
};

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

    int n, m;
    cin >> n >> m;
    BellmanFord<> bf;

    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        bf.E.push_back({a, b, -c});
    }

    if (bf.calc_and_find_negative_loop(1, n)) cout << "inf" << endl;
    else cout << -bf.d[n] << endl;

    REP(i, 1, n + 1) cerr << bf.d[i] << endl;

    return 0;
}


Measured memory_bytes: 512