n,m,p=gets.chomp.split(" ").map(&:to_i)
score = -1

edges = []
m.times do 
    a,b,c=gets.chomp.split(" ").map(&:to_i)
    edges.push([a,b,p-c])
end

# Step 1: グラフの初期化
vertices = Array.new(n) {|x| [x==0 ? 0 : nil, nil] }

# Step 2: 辺の緩和を反復
n.times do
    edges.each do |edge|
        u = edge[0]
        v = edge[1]
        u_distance = vertices[u-1][0]
        v_distance = vertices[v-1][0]
        next if u_distance == nil
        if v_distance == nil || v_distance > u_distance + edge[2]
            vertices[v-1][0] = u_distance + edge[2]
            vertices[v-1][1] = u
        end
    end
end

ans = -1 * vertices[n-1][0]
ans = ans < 0 ? 0 : ans
via = [n]
g = n
while true do
    g = vertices[g-1][1]
    via.push(g)
    break g == 1
end
# Step 3: 負の重みの閉路がないかチェック
edges.each do |edge|
    u = edge[0]
    v = edge[1]
    u_distance = vertices[u-1][0]
    v_distance = vertices[v-1][0]
    next if u_distance == nil
    if u_distance + edge[2] < v_distance && (via.include?(u) || via.include?(v))
        ans = -1
        break
    end
end

puts ans
