#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &__ins_, vector<T> &__v_) {
  for (T &__dst_ : __v_) __ins_ >> __dst_;
  return __ins_;
}
template <typename F, typename S>
istream &operator>>(istream &__ins_, pair<F, S> &__p_) {
  return __ins_ >> __p_.first >> __p_.second;
}
void in() {}
template <typename T, typename... Args>
void in(T &__dst_, Args &...__args_) {
  cin >> __dst_;
  in(__args_...);
}
template <typename F, typename S>
ostream &operator<<(ostream &__outs_, pair<F, S> const &__p_) {
  return __outs_ << "(" << __p_.first << ", " << __p_.second << ")";
}
template <typename T>
ostream &operator<<(ostream &__outs_, vector<T> const &__v_) {
  for (size_t i = 0; i < __v_.size(); ++i) {
    if (i > 0) __outs_ << " ";
    __outs_ << __v_[i];
  }
  return __outs_;
}
void out(char const *, ostream &) {}
template <typename T, typename... Args>
void out(char const *__prefix_, ostream &__outs_, T const &__src_,
         Args const &...__args_) {
  out(__prefix_, __outs_ << __prefix_ << __src_, __args_...);
}
template <typename T, typename... Args>
void out(T const &__src_, Args const &...__args_) {
  out(" ", cout << __src_, __args_...);
}
void outln() { cout << endl; }
template <typename... Args>
void outln(Args const &...__args_) {
  out(__args_...);
  outln();
}
int const mod = (int)1e9 + 7;
int const inf = (int)1e9 + 999;
long long const infl = (long long)2e18 + 999;
double const eps = 1e-10;
double const seps = 1e-7;
double const pi = 4.0 * atan(1.0);
long double const pil = 4.0 * atan(1.0L);
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(numeric_limits<double>::digits10);
  cerr << setprecision(numeric_limits<long double>::digits10);
  solve();
  return 0;
}
static int const N = 5002;
static vector<pair<short, int>> g[N];
static int t[N][N];
static char visited[N];
static short nxt[N][N];
static inline void dfs(int const u, int const n) {
  if (visited[u]) {
    return;
  }
  visited[u] = true;
  for (pair<short, int> const e : g[u]) {
    dfs(e.first, n);
    for (int i = 1; i <= n; ++i) {
      int const r = t[e.first][i - 1] - e.second;
      if (r > t[u][i]) {
        t[u][i] = r;
        nxt[u][i] = e.first;
      }
    }
  }
}
void solve() {
  fill(&t[0][0], &t[N][0], -inf);
  int n, m, c;
  in(n, m, c);
  for (int i = 0; i < m; ++i) {
    int u, v, w;
    in(u, v, w);
    --u;
    --v;
    g[u].emplace_back(v, w);
  }
  t[n - 1][1] = c;
  visited[n - 1] = true;
  dfs(0, n);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (t[0][i] >= 0) {
      ans = max(ans, i);
    }
  }
  outln(ans);
  int node = 0;
  for (int i = ans; i > 0; --i) {
    out(node + 1, "");
    node = nxt[node][i];
  }
  outln();
}
