#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
using namespace std;
#define MOD 1000000007
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long double EPS = 1e-10;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll cost;
class Edge {
public:
	ll src;
	ll dest;
	ll weight;
	bool rev;
	Edge() {}
	Edge(ll f, ll t, ll w, bool r)
	{
		src = f;
		dest = t;
		weight = w;
		rev = r;
	}
};
class Vertex {
public:
	ll no;
	ll point;
	ll visitedCnt;
	bool cango;
	vector<Edge> edges;
	Vertex() {}
	Vertex(ll n, ll p) {
		no = n;
		point = p;
		visitedCnt = 0;
		cango = false;
	}
	bool operator < (const Vertex& v2) const {
		return this->point < v2.point;
	};
};
class Graph {
private:
public:
	map<ll, Vertex> vmap;
	map<ll, vector<Edge>> emap;
	vector<Edge> edges;
	Graph() {
	}
	void addEdge(ll src, ll dest, ll weight, bool rev) {
		if (vmap.count(src) == 0) {
			Vertex vf(src, 0);
			vmap[src] = vf;
		}
		if (vmap.count(dest) == 0) {
			Vertex vf(dest, 0);
			vmap[dest] = vf;
		}
		Edge e(src, dest, weight, rev);
		emap[src].push_back(e);
		edges.push_back(e);
	}

	void checkEdge(ll no) {
		if (vmap[no].cango) return;
		vmap[no].cango = true;
		REP(i, emap[no].size()) {
			Edge& e = emap[no][i];
			checkEdge(e.dest);
		}
	}
	ll BellmanFord() {
		vmap[0].point = 0;
		for (int i = 1; i < (int)vmap.size(); i++) {
			vmap[i].point = -INF;
		}
		for (int i = 0; i < (int)vmap.size() - 1; i++) {
			bool updated = false;
			for (int k = 0; k < (int)edges.size(); k++) {
				Edge& e = edges[k];
				Vertex& u = vmap[e.src];
				Vertex& v = vmap[e.dest];
				ll getPoint = u.point + e.weight - cost;
				if (v.point < getPoint) {
					v.point = getPoint;
					updated = true;
				}
			}
			if (!updated) {
				break;
			}
		}

		REP(k, edges.size()) {
			Edge& e = edges[k];
			Vertex& u = vmap[e.src];
			Vertex& v = vmap[e.dest];
			if (v.point == -INF) continue;
			ll pp = u.point + e.weight - cost;
			if (pp > v.point) {
				return -1;
			}
		}

		Vertex& vg = vmap[vmap.size() - 1];
		if (vg.point < 0) return 0;
		return vg.point;
	}
	ll Dijkstra() {
		vmap[0].point = 0;
		vmap[0].visitedCnt = 1;

		priority_queue<Vertex, vector<Vertex>> pq;
		pq.push(vmap[0]);
		while (!pq.empty()) {
			Vertex v = pq.top();
			pq.pop();

			REP(i, v.edges.size()) {
				Edge& e = v.edges[i];
				ll getPoint = v.point + e.weight - cost;
				if (vmap[e.dest].point < getPoint) {
					vmap[e.dest].point = getPoint;
					pq.push(vmap[e.dest]);
				}
			}
		}
		return vmap[vmap.size() - 1].point;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n, m, p;
	cin >> n >> m >> p;
	cost = p;
	Graph g;
	Graph rg;
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g.addEdge(a, b, c, false);
		rg.addEdge(b, a, c, false);
	}
	g.checkEdge(0);
	rg.checkEdge(n - 1);

	Graph newg;
	REP(i, n) {
		if (!g.vmap[i].cango || !rg.vmap[i].cango) {
			continue;
		}
		REP(k, g.emap[i].size()) {
			newg.addEdge(g.emap[i][k].src, g.emap[i][k].dest, g.emap[i][k].weight, false);
		}
	}
	ll ret = newg.BellmanFord();

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 2936