// AtCoder abc 061
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

typedef long long llong;

// const int INF = 1 << 30; // sufficiently large number
// const llong INF = 1000000000000;
const llong INF = 1LL << 60;
const int N_NODES_MAX = 1010;
// const int N_EDGES_MAX = 2020;                     

// input
//   |N M
//   |a1 b1 c1
//   |a2 b2 c2
//   |...
//   |aM bM cM
// N: n_nodes 2 ~ 1000
// M: n_edges 1 ~ min(N^2, 2000)

bool bellman_ford(vector< pair<int, llong> > *adj,
                  int n_nodes,
                  int src,
                  llong *dist,
                  int *pred,
                  bool *nega)
{
  // Step1. Initializing Graph
  for (int nd = 1; nd <= n_nodes; nd++) {
    if (nd == src) {
      dist[nd - 1] = 0;
    } else {
      dist[nd - 1] = INF;
    }
    pred[nd - 1] = -1;
  }

  // Step2. Relaxing Edges
  int st, ed;
  llong wt, tmp_wt;
  int n_relax;
  for (int loop = 1; loop <= n_nodes - 1; ++loop) {
    n_relax = 0;
    for (st = 1; st <= n_nodes; ++st) {
      for (auto itr = adj[st - 1].begin(); itr != adj[st - 1].end(); ++itr) {
        ed = itr->first;
        wt = itr->second;
        if (dist[st - 1] == INF) continue;
        tmp_wt = dist[st - 1] + wt;
        if (tmp_wt < dist[ed - 1]) {
          n_relax += 1;
          dist[ed - 1] = tmp_wt;
          pred[ed - 1] = st;
        }
      }
    }
    if (n_relax == 0) {
      break;
    }
  }

  // Step3. Checking Negative-Weight Cycles
  // for (st = 1; st <= n_nodes; st++) {
  //   for (auto itr = adj[st - 1].begin(); itr != adj[st - 1].end(); ++itr) {
  //     ed = itr->first;
  //     wt = itr->second;
  //     if (dist[st - 1] + wt < dist[ed - 1]) {
  //       return false;
  //     }
  //   }
  // }
  // return true;
  for (int nd = 1; nd <= n_nodes; ++nd) {
    nega[nd - 1] = false;
  }
  for (int loop = 1; loop <= n_nodes; ++loop) {
    for (st = 1; st <= n_nodes; ++st) {
      for (auto itr = adj[st - 1].begin(); itr != adj[st - 1].end(); ++itr) {
        ed = itr->first;
        wt = itr->second;
        if (dist[st - 1] == INF) continue;
        tmp_wt = dist[st - 1] + wt;
        if (tmp_wt < dist[ed - 1]) {
          dist[ed - 1] = tmp_wt;
          nega[ed - 1] = true;
        }
        if (nega[st - 1] == true) {
          nega[ed - 1] = true;
        }
      }
    }    
  }
  if (nega[n_nodes - 1]) return false;
  else return true;
}

void print_adj_list(vector< pair<int, int> > * adj, int n_nodes)
{
  for (int i = 1; i <= n_nodes; i++) {
    cout << i << ": ";
    for (auto itr = adj[i - 1].begin(); itr != adj[i - 1].end(); ++itr) {
      cout << "(" << itr->first << ", " << itr->second << ")" << " ";
    }
    cout << endl;
  }
}

int main(int argc, char *argv[])
{
  int N; // n_nodes ~ 1e3
  int M; // n_edges ~ 2e3
  vector< pair<int, llong> > adj[N_NODES_MAX];
  int a, b;
  llong c;
  pair<int, llong> tmp_pair;
  
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    cin >> a >> b >> c;
    tmp_pair.first = b;
    tmp_pair.second = -c;
    adj[a - 1].push_back(tmp_pair);
  }
  // print_adj_list(adj, N);

  llong dist[N_NODES_MAX];
  int pred[N_NODES_MAX];
  bool nega[N_NODES_MAX];
  
  bool flag;
  flag = bellman_ford(adj, N, 1, dist, pred, nega);

  if (flag) {
    cout << -dist[N - 1] << endl;
  } else {
    cout << "inf" << endl;
  }
  
  // if (not tf_flag) {
  //   cout << "inf" << endl;
  // } else {
  //   cout << -dist[N - 1] << endl;
  // }
    
  return 0;
}


Measured memory_bytes: 384