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)] }

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

def reachable(s, g)
  q=[s]
  result = Set.new([s])
  until q.empty?
    c = q.shift
    g[c].each do |to, _|
      next if result.include?(to)
      result.add(to)
      q.push(to)
    end
  end
  result
end

# 不要な閉路の削除
# 必要なノードの算出
from_1 = reachable(1, graph)
from_n = reachable(n, r_graph)
availables = from_1 & from_n

# BFする
INF = 10**13
dist = Array.new(n+1, INF)
dist[1]=0
updated = false

edges = edges.select {|from, to, cost| availables.include?(from) && availables.include?(to) }

n.times do
  updated = false
  edges.each do |from, to, cost|
    if dist[from]!=INF && dist[to] > dist[from]+cost
      dist[to] = dist[from]+cost
      updated = true
    end
  end
  break unless updated
end
if updated
  p -1
  exit
end

# 答えだす
#p availables
#p edges
#p dist
#p [dist[n]*-1, 0]
p [dist[n]*-1, 0].max
