local unpack = table.unpack or unpack
local INF = 10123456789
local N, M, P = io.read("*n", "*n", "*n")
if N * M > 10^5 then
    error()
    return
end
local edges = {}
for i=1,M do
    local a, b, c = io.read("*n", "*n", "*n")
    edges[i] = {a, b, -1 * (c - P)}
end
local function bf()
    local d = {}
    for i=1,N do
        d[i] = INF
    end
    d[1] = 0
    for i=1,N-1 do
        for j=1,M do
            local a, b, w = unpack(edges[j])
            if d[a] ~= INF then
                local new_d = d[a] + w
                if new_d < d[b] then
                    d[b] = new_d
                end
            end
        end
    end
    return d
end
local d = bf()
print(-d[N])
