#include <iostream>
using namespace std;

typedef long long ll;
const ll INF = 3000000000000;
struct edge{int from, to; ll cost;};

int main()
{
  int N, M; cin >> N >> M;
  edge es[M];
  for (int i = 0; i < M; i++) {
    cin >> es[i].from >> es[i].to >> es[i].cost;
    es[i].cost *= -1;
  }

  ll d[N+1];
  fill(d, d + N + 1, INF);
  d[1] = 0;
  bool INF_flag = false;
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < M; i++) {
      int from = es[i].from, to = es[i].to; ll cost = es[i].cost;
      if (d[from] != INF && d[to] > d[from] + cost) {
        d[to] = d[from] + cost;
        if (k == N-1 && to == N)
          INF_flag = true;
      }
    }
  }

  if (INF_flag) cout << "inf" << endl;
  else cout << -d[N] << endl;
}

