using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int pointCount = inpt[0];

        canReach = new bool[pointCount+1];
        for (int i = 0; i < inpt[1]; i++)
        {
            long[] inpt2 = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            int fromPoint = (int)inpt2[0];
            int toPoint = (int)inpt2[1];
            if (!Road.ContainsKey(fromPoint))
            {
                Road.Add(fromPoint, new Dictionary<int, long>());
            }
            Road[fromPoint][toPoint] = inpt2[2];
            if (!RoadRev.ContainsKey(toPoint))
            {
                RoadRev.Add(toPoint, new Dictionary<int, long>());
            }
            RoadRev[toPoint][fromPoint] = inpt2[2];
        }

        //　ゴール頂点を含むループがあるか確認
        Queue<int> que = new Queue<int>();
        canReach[pointCount] = true;
        RoadRev[pointCount].ToList().ForEach(a =>
        {
            canReach[a.Key] = true;
            que.Enqueue(a.Key);
        });
        while (que.Count > 0)
        {
            int current = que.Dequeue();
            if (!RoadRev.ContainsKey(current))
            {
                continue;
            }
            RoadRev[current].ToList().ForEach(a =>
            {
                if (!canReach[a.Key])
                {
                    canReach[a.Key] = true;
                    que.Enqueue(a.Key);
                }
            });
        }
        bool[] flags = new bool[pointCount+1];
        flags[1] = true;
        long ans = GetAns(1, flags);
        if (ans == long.MaxValue)
        {
            Console.WriteLine("inf");
        }
        else
        {
            Console.WriteLine(ans);
        }
    }



    private Dictionary<int, Dictionary<int, long>> Road = new Dictionary<int, Dictionary<int, long>>();
    private Dictionary<int, Dictionary<int, long>> RoadRev = new Dictionary<int, Dictionary<int, long>>();
    private bool[] canReach;

    private Dictionary<int, long> dic = new Dictionary<int, long>();

    private long GetAns(int pos, bool[] flag)
    {
        if (dic.ContainsKey(pos))
        {
            return dic[pos];
        }
        if (!Road.ContainsKey(pos))
        {
            if (pos == flag.Length - 1)
            {
                dic.Add(pos, 0);
                return 0;

            }
            else
            {
                dic.Add(pos, long.MinValue);
                return long.MinValue;
            }
        }
        long ans = long.MinValue;
        if (pos == flag.Length - 1)
        {
            ans = 0;
        }
        foreach (int nextPos in Road[pos].Keys)
        {
            if(!canReach[nextPos]) {
                continue;
            }
            if (flag[nextPos])
            {
                if (IsPositiveRoop(pos, nextPos))
                {
                    ans = long.MaxValue;
                    break;
                }
                else
                {
                    continue;
                }
            }
            else
            {
                flag[nextPos] = true;
                long rete = GetAns(nextPos, flag);
                flag[nextPos] = false;
                if (rete == long.MaxValue)
                {
                    ans = long.MaxValue;
                    break;
                }
                else if (rete == long.MinValue)
                {
                    continue;
                } else if(ans == long.MinValue) 
                {
                    ans = rete + Road[pos][nextPos];
                }
                else
                {
                    ans = Math.Max(ans, rete + Road[pos][nextPos]);
                }
            }
        }
        dic[pos] = ans;
        return ans;
    }


    private bool IsPositiveRoop(int pos1, int pos2)
    {
        Queue<int> que = new Queue<int>();
        Nullable<long>[] score = new Nullable<long>[canReach.Length];
        score[pos1] = 0;
        que.Enqueue(pos1);
        while (que.Count > 0)
        {
            int current = que.Dequeue();
            if (!Road.ContainsKey(current))
            {
                continue;
            }
            foreach (int next in Road[current].Keys)
            {
                long nextVal = score[current].Value + Road[current][next];
                if (score[next] == null || (score[next].Value < 0 && nextVal >= 0) || (score[next].Value == 0 && nextVal > 0))
                {
                    score[next] = nextVal;
                    if (next != pos2)
                    {
                        que.Enqueue(next);
                    }
                }
            }
        }
        long max1 = score[pos2].Value;
        score = new Nullable<long>[canReach.Length];
        score[pos2] = 0;
        que.Enqueue(pos2);
        while (que.Count > 0)
        {
            int current = que.Dequeue();
            if (!Road.ContainsKey(current))
            {
                continue;
            }
            foreach (int next in Road[current].Keys)
            {
                long nextVal = score[current].Value + Road[current][next];
                if (score[next] == null || (score[next].Value < 0&& nextVal>=0) || (score[next].Value == 0 && nextVal > 0))
                {
                    score[next] = nextVal;
                    if (next != pos1)
                    {
                        que.Enqueue(next);
                    }
                } 
            }
        }
        long max2 = score[pos1].Value;
        return (max1 + max2 > 0);

    }

    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 -1000000000
5 6 -1000000000



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 26208