#include <bits/stdc++.h>
#define inf (long long)1e18
using namespace std;

struct data {
  long long a, b, c;
};

long long n, m, p;
long long dist[2600] = {0};
vector<data> edge;

long long solve();
bool bell();

int main() {
  cin >> n >> m >> p;
  for(int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    edge.push_back({--a, --b, p - c});
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int i = 0; i < n; ++i) dist[i] = inf;
  dist[0] = 0;
  for(int i = 0; i < n - 1; ++i) bell();
  for(int i = 0; i < n; ++i)
    if(bell()) return -1;
  return max(-dist[n - 1], 0LL);
}

bool bell() {
  bool ch = 0;
  for(int i = 0; i < m; ++i) {
    data now = edge[i];
    if(dist[now.a] != inf &&
       dist[now.b] > dist[now.a] + now.c) {
      if(now.b == n - 1) ch = 1;
      dist[now.b] = dist[now.a] + now.c;
    }
  }
  return ch;
}