import std.stdio, std.algorithm, std.conv, std.array, std.string, std.typecons;

alias Edge = Tuple!(int, "a", int, "b", int, "c");

Edge[2000] EDGES;
long[1000] VERTICES = long.max;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto n = nm[0];
    auto m = nm[1];

    foreach (i; 0..m) {
        auto abc = readln.split.to!(int[]);
        EDGES[i] = Edge(abc[0]-1, abc[1]-1, -abc[2]);
    }

    VERTICES[0] = 0;

    long memo;

    foreach (i; 0..n) {
        foreach (j, edge; EDGES[0..m]) {
            auto a = VERTICES[edge.a];
            auto b = VERTICES[edge.b];
            auto c = edge.c;
            if (a == long.max || b > a + c) VERTICES[edge.b] = a + c;
        }
        if (i == n-2) memo = VERTICES[m-1];
        if (i == n-1 && memo > VERTICES[m-1]) {
            writeln("inf");
            return;
        }
    }

    writeln(-VERTICES[n-1]);
}