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 << 50;

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 Edge!long[][](N);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        auto u = s[0] - 1;
        auto v = s[1] - 1;
        long c = -s[2] + P;
        G[u] ~= Edge!long(v, c);
    }

    auto dist = bellman_ford!(long, INF)(G, 0);

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

struct Edge(T) {
    int to;
    T cost;
}

T[] bellman_ford(T, T inf)(const Edge!(T)[][] graph, int start) {
    int n = graph.length.to!int;
    auto dist = new T[](n);
    dist[] = inf;
    dist[start] = 0;

    foreach (i; 0..n) {
        foreach (u; 0..n) {
            foreach (e; graph[u]) {
                if (dist[u] != inf && dist[e.to] > dist[u] + e.cost) {
                    dist[e.to] = dist[u] + e.cost;
                    if (i == n - 1) {
                        dist[e.to] = -inf;
                    }
                }
            }
        }
    }

    auto stack = new int[](n);
    int sp = 0;

    foreach (i; 0..n) {
        if (dist[i] == -inf) {
            stack[sp++] = i;
        }
    }

    while (sp > 0) {
        int u = stack[--sp];
        foreach (e; graph[u]) {
            if (dist[e.to] == -inf) continue;
            dist[e.to] = -inf;
            stack[sp++] = e.to;
        }
    }

    return dist;
}
