/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const long long INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

struct edge{
	LL from;
	LL to;
	LL cost;
};

LL V, m, x;
LL d[5505];
edge tab[5505];

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

void Bellman_Ford(int s) {
	for(int i = 0;i < V; i++){
		d[i] = INF;
	}
    d[s] = 0;
    for(int j = 0; j < 2*V; j++){
        bool update = false;
        for(int i = 0; i < m; i++){
            edge e = tab[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (j >= V) d[e.to] = - INF;
                //cout << e.from << " " << e.to << " " << e.cost << " " << d[e.to] << endl;
                update = true;
            }
        }
        if (!update) break;
    }
}
/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
	cin >> V >> m >> x;
	for(int i = 0; i < m; i++){
		LL v1, v2, v3;
		cin >> v1 >> v2 >> v3;
		v1--; v2--;
		v3 *= (-1);
		v3 += x;
		tab[i].from = v1;
		tab[i].to = v2;
		tab[i].cost = v3;
	}
	
	Bellman_Ford(0);
	
	if(d[V - 1] <= -INF) cout << "-1" << '\n';
	else cout << max(0LL, -d[V-1]) << '\n';
	
	
	return 0;
}


Measured memory_bytes: 384