import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto P = s[2].to!long;
    auto G = new Tuple!(int, long)[][](N);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        auto u = s[0] - 1;
        auto v = s[1] - 1;
        auto c = -s[2].to!long + P;
        G[u] ~= tuple(v, c);
    }

    auto dist = new long[](N);
    dist[]= INF;
    dist[0] = 0;

    foreach (i; 0..N) {
        foreach (v; 0..N) {
            foreach (to; G[v]) {
                int u = to[0];
                long c = to[1];
                if (dist[v] != INF && dist[u] > dist[v] + c) {
                    dist[u] = dist[v] + c;
                    if (i == N - 1) {
                        dist[u] = -INF;
                    }
                }
            }
        }
    }

    if (dist[N-1] == -INF || dist[N-1] == INF) {
        writeln(-1);
    } else {
        writeln(max(0L, -dist[N-1]));
    }
}
