def bellman_ford(V, E, s, std):

  dist = [float('inf') for _ in range(V)]

  dist[s] = 0

  for i in range(V):

    for s, t, d in std:

      s -=1

      t -= 1

      d = -d

      if dist[t] > dist[s] + d:

        dist[t] = dist[s] + d 

        if i == V-1 and t+1 == V:

          return -1 

  return dist



def main():

  N, M = list(map(int, input().split()))

  abc = [list(map(int, input().split())) for _ in range(M)]

  dist = bellman_ford(N, M, 0, abc)

  if dist == -1:

    print('inf')

    exit()

  else:

    print((-dist[N-1]))



if __name__ == "__main__":

  main()


n, m = list(map(int, input().split()))

abc = []

for _ in range(m):

  a, b, c = list(map(int, input().split()))

  a -= 1

  b -= 1

  c *= -1

  abc += [[a,b,c]]



def bellman_ford(s):

  # std = [[s0, t0, d0], [s1, t1, d1], ... , [sm, tm, dm]]

  # (si, ti, di): si, ti間に重さdiの辺がある

  dist = [float('inf')]*n 

  dist[s] = 0

  for u in range(n):

    for s, t, d in abc:

      if dist[t] > dist[s] + d:

        dist[t] = dist[s] + d

        if u == n-1 and t == n-1:

          return -1

  return dist



dist = bellman_ford(0)

if dist == -1:

  print('inf')

else:

  print((-1*dist[n-1]))



def bellman_ford(V, E, s, std):
    dist = [float("inf") for _ in range(V)]
    dist[s] = 0
    for i in range(V):
        for s, t, d in std:
            s -= 1
            t -= 1
            d = -d
            if dist[t] > dist[s] + d:
                dist[t] = dist[s] + d
                if i == V - 1 and t + 1 == V:
                    return -1
    return dist


def main():
    N, M = list(map(int, input().split()))
    abc = [list(map(int, input().split())) for _ in range(M)]
    dist = bellman_ford(N, M, 0, abc)
    if dist == -1:
        print("inf")
        exit()
    else:
        print((-dist[N - 1]))


if __name__ == "__main__":
    main()

n, m = list(map(int, input().split()))
abc = []
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    c *= -1
    abc += [[a, b, c]]


def bellman_ford(s):
    # std = [[s0, t0, d0], [s1, t1, d1], ... , [sm, tm, dm]]
    # (si, ti, di): si, ti間に重さdiの辺がある
    dist = [float("inf")] * n
    dist[s] = 0
    for u in range(n):
        for s, t, d in abc:
            if dist[t] > dist[s] + d:
                dist[t] = dist[s] + d
                if u == n - 1 and t == n - 1:
                    return -1
    return dist


dist = bellman_ford(0)
if dist == -1:
    print("inf")
else:
    print((-1 * dist[n - 1]))

-def bellman_ford(V, E, s, std): -    dist = [float("inf") for _ in range(V)] +n, m = list(map(int, input().split())) +abc = [] +for _ in range(m): +    a, b, c = list(map(int, input().split())) +    a -= 1 +    b -= 1 +    c *= -1 +    abc += [[a, b, c]] + + +def bellman_ford(s): +    # std = [[s0, t0, d0], [s1, t1, d1], ... , [sm, tm, dm]] +    # (si, ti, di): si, ti間に重さdiの辺がある +    dist = [float("inf")] * n -    for i in range(V): -        for s, t, d in std: -            s -= 1 -            t -= 1 -            d = -d +    for u in range(n): +        for s, t, d in abc: -                if i == V - 1 and t + 1 == V: +                if u == n - 1 and t == n - 1: -def main(): -    N, M = list(map(int, input().split())) -    abc = [list(map(int, input().split())) for _ in range(M)] -    dist = bellman_ford(N, M, 0, abc) -    if dist == -1: -        print("inf") -        exit() -    else: -        print((-dist[N - 1])) - - -if __name__ == "__main__": -    main() +dist = bellman_ford(0) +if dist == -1: +    print("inf") +else: +    print((-1 * dist[n - 1]))