#include <bits/stdc++.h>
using namespace std;
queue<pair<long long, long long> > q;
int32_t trace[5005][5005];
int32_t n, m, t, dp[5005][5005];
vector<pair<long long, long long> > adj[5005];
void solve() {
  dp[1][1] = -t - 1;
  q.emplace(1, 1);
  while (q.size()) {
    long long node = q.front().first, cnt = q.front().second;
    q.pop();
    for (auto i : adj[node]) {
      if (dp[i.first][cnt + 1] > dp[node][cnt] + i.second) {
        dp[i.first][cnt + 1] = dp[node][cnt] + i.second;
        q.emplace(i.first, cnt + 1);
        trace[i.first][cnt + 1] = node;
      }
    }
  }
}
signed main() {
  cin >> n >> m >> t;
  for (long long i = 1; i <= m; i++) {
    long long u, v, val;
    cin >> u >> v >> val;
    adj[u].emplace_back(v, val);
  }
  solve();
  stack<long long> ans;
  for (long long i = n; i >= 1; i--) {
    if (dp[n][i] < 0) {
      cout << i << endl;
      long long tr = n;
      while (i > 0) {
        ans.push(tr);
        tr = trace[tr][i];
        i--;
      }
    }
  }
  while (ans.size()) {
    cout << ans.top() << " ";
    ans.pop();
  }
}
