require 'set'

n, m, tax = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }
abc = abc.map {|a, b, c| [a, b, -1*(c-tax)] }

# get adjuscent list
graph = Array.new(n+1) { [] }
r_graph = Array.new(n+1) { [] }
abc.each do |a, b, c|
  graph[a] << b
  r_graph[b] << a
end

# build from_1 from_n
def reachable(s, g)
  q=[s]
  visited = Set.new()
  until q.empty?
    from = q.shift
    next if visited.include?(from)
    visited.add(from)
    g[from].each do |to|
      next if visited.include?(to)
      visited.add(to)
      q.push(to)
    end
  end

  visited
end

from_1 = reachable(1, graph)
from_n = reachable(n, r_graph)
av = from_1 & from_n
edges=abc.select {|a, b, c| av.include?(a) && av.include?(b) }

#p av
#p edges

# b-f method
updated = false
INF= 10**12
dist = Array.new(n+1, INF)
dist[1]=0
n.times do
  updated = false
  edges.each do |from, to, cost|
    next if dist[from]==INF || dist[to] <= dist[from] + cost

    dist[to] = dist[from] + cost
    updated = true
  end
  break unless updated
end

if updated
  p -1
  exit
end

# answer
p [0, -dist[n]].max


