/*
csc -debug E.cs && mono --debug E.exe <<< "3 3 10
1 2 20
2 3 30
1 3 45"
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var N = cin.NextInt();
        var M = cin.NextInt();
        var P = cin.NextInt();

        var edges = new List<int[]>(); // [(u,v,c)]
        var adj = Helpers.CreateArray(N + 1, _ => new List<int[]>()); // u -> [(u,v,c)]
        var revAdj = Helpers.CreateArray(N + 1, _ => new List<int[]>()); // v -> [(u,v,c)]

        for (var i = 0; i < M; i++) {
            var uvc = cin.IntArray();
            uvc[2] = - (uvc[2] - P);
            edges.Add(uvc);
            adj[uvc[0]].Add(uvc);
            revAdj[uvc[1]].Add(uvc);
        }

        var used = new bool[N + 1];
        {
            var Q = new Queue<int>();
            Q.Enqueue(N);
            used[N] = true;
            while (Q.Count > 0) {
                var v = Q.Dequeue();
                foreach (var uvc in revAdj[v]) {
                    var u = uvc[0];
                    if (!used[u]) {
                        used[u] = true;
                        Q.Enqueue(u);
                    }
                }
            }
        }

// System.Console.WriteLine(used.Join());

        if (!used[1]) {
            System.Console.WriteLine(-1);
            return;
        }

        // BF
        var INF = 1000000000000L;
        var D = Helpers.CreateArray(N + 1, _ => INF);
        D[1] = 0;
        for (var len = 1; len <= N; len++) {
            var changed = false;
            foreach (var uvc in edges) {
                var u = uvc[0];
                var v = uvc[1];
                var c = (long)uvc[2];
                if (used[u] && used[v] && D[u] != INF && D[v] > D[u] + c) {
                    D[v] = D[u] + c;
                    changed = true;
                }
            }
// System.Console.WriteLine(new { len, D = D.Join() });
            if (len == N && changed) {
                System.Console.WriteLine(-1);
                return;
            }
        }

        System.Console.WriteLine(Math.Max(0L, -D[N]));
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 15496