n, m, point = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1) { [] }

abc.each do |a, b, c|
  graph[a] << [b, (c-point)*-1]
end

INF = Float::INFINITY
dist = Array.new(n+1, INF)
dist[1]=0

(1..n).each do |i|
  (1..n).each do |v|
    graph[v].each do |g|
      if dist[v] != INF && dist[g.first] > dist[v] + g.last
        dist[g.first] = dist[v] + g.last
        if i==n
          if dist[n]!=INF
            p [-dist[n], 0].max
          else
            p -1
          end
          exit
        end
      end
    end
  end
end

p -dist[n]
