using System;
using System.Collections.Generic;

namespace AtCoder
{
    static class Solver
    {
        static IO io = new IO();

        public static void Solve()
        {
            io.ReadSplit();
            int N = io.Int();
            int M = io.Int();

            Node[] nodes = new Node[N + 1];
            Edge[] edges = new Edge[M];

            for (int i = 1; i <= N; ++i)
            {
                Node n = new Node();
                n.edges = new List<Edge>();
                if (i == 1)
                {
                    n.total_c = 0;
                }
                else
                {
                    n.total_c = long.MinValue;
                }
                nodes[i] = n;
            }

            for (int i = 0; i < M; ++i)
            {
                io.ReadSplit();
                Edge e = new Edge();
                e.a = io.Int();
                e.b = io.Int();
                e.c = io.Int();
                edges[i] = e;
                nodes[e.a].edges.Add(e);
            }

            for (int i = 0; i < N; ++i)
            {
                foreach (Edge e in edges)
                {
                    if (long.MinValue < nodes[e.a].total_c)
                    {
                        if (nodes[e.b].total_c < nodes[e.a].total_c + e.c)
                        {
                            nodes[e.b].total_c = nodes[e.a].total_c + e.c;
                        }
                    }
                }
            }
            long ans = nodes[N].total_c;

            for (int i = 0; i < N; ++i)
            {
                foreach (Edge e in edges)
                {
                    if (long.MinValue < nodes[e.a].total_c)
                    {
                        if (nodes[e.b].total_c < nodes[e.a].total_c + e.c)
                        {
                            nodes[e.b].total_c = nodes[e.a].total_c + e.c;
                        }
                    }
                }
            }

            if (ans < nodes[N].total_c)
            {
                io.WriteLine("inf");
            }
            else
            {
                io.WriteLine(nodes[N].total_c.ToString());
            }
        }
    }
    public struct Node
    {
        public List<Edge> edges;
        public long total_c;
    }
    public struct Edge
    {
        public int a;
        public int b;
        public int c;
    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver.Solve();
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

Measured memory_bytes: 13248