#include<bits/stdc++.h>
using namespace std;
int e[2005][3];
long long dis[1005];
int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++ i) {
        scanf("%d%d%d", &e[i][0], &e[i][1], &e[i][2]);
        -- e[i][0], -- e[i][1];
    }
    memset(dis, -0x3f, sizeof(dis));
    dis[0] = 0;
    for (int t = 0; t < 5 * m; ++ t) {
        for (int i = 0; i < m; ++ i) {
            int u = e[i][0];
            int v = e[i][1];
            int w = e[i][2];
            if (dis[v] < dis[u] + w) {
                dis[v] = dis[u] + w;
                if (v == n - 1 && t >= 3 * m) {
                    puts("inf"); return 0;
                }
            }
        }
    }
    printf("%lld\n", dis[n - 1]);
    return 0;
}
