package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	P, _ := strconv.Atoi(read())
	cost := make([][]int, M)
	to, ot := make([][]int, 2505), make([][]int, 2505)
	d := make([]int, N)
	for i := 0; i < N; i++ {
		to[i] = make([]int, 0, 2505)
		ot[i] = make([]int, 0, 2505)
		d[i] = 1e9
	}
	d[0] = 0
	for i := 0; i < M; i++ {
		cost[i] = make([]int, 3)
		a, _ := strconv.Atoi(read())
		b, _ := strconv.Atoi(read())
		c, _ := strconv.Atoi(read())
		cost[i] = []int{a - 1, b - 1, (c - P) * (-1)}
		to[a-1] = append(to[a-1], b-1)
		ot[b-1] = append(ot[b-1], a-1)
	}
	dfs0(0, to)
	dfsN(N-1, ot)
	ok := make([]bool, 2505)
	for i := 0; i < N; i++ {
		ok[i] = check_0[i] && check_N[i]
	}

	var update bool = true
	var step int
	for update {
		update = false
		for i := 0; i < M; i++ {
			a, b, c := cost[i][0], cost[i][1], cost[i][2]
			if !ok[a] || !ok[b] {
				continue
			}
			if d[a]+c < d[b] {
				d[b] = d[a] + c
				update = true
			}
		}
		step++
		if N < step {
			fmt.Println(-1)
			return
		}
	}
	ans = d[N-1] * (-1)
	ans = max(ans, 0)
	fmt.Println(ans)
}

var check_0 = [2505]bool{}

func dfs0(x int, to [][]int) {
	if check_0[x] {
		return
	}
	check_0[x] = true
	for _, value := range to[x] {
		dfs0(value, to)
	}
}

var check_N = [2505]bool{}

func dfsN(x int, ot [][]int) {
	if check_N[x] {
		return
	}
	check_N[x] = true
	for _, value := range ot[x] {
		dfsN(value, ot)
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 25344