#include <bits/stdc++.h>
using namespace std;
const int mxN = 5e3 + 33;
vector<pair<int, int> > g[mxN + 33];
vector<vector<int> > dp, p;
int n, m, T;
void dfs(int v, int cnt = 1, int t = 0, int pr = 0) {
  if (t > T || t >= dp[v][cnt]) {
    return;
  }
  dp[v][cnt] = t;
  p[v][cnt] = pr;
  for (auto &i : g[v]) {
    dfs(i.first, cnt + 1, t + i.second, v);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> T;
  dp.assign(n + 1, vector<int>(n + 1, 1e9 + 33));
  p.resize(n + 1, vector<int>(n + 1));
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    g[x].push_back({y, w});
  }
  dfs(0);
  int mx = 1, lst = n - 1;
  for (int i = 1; i <= n; i++) {
    if (dp[n - 1][i] <= T) {
      mx = max(mx, i);
    }
  }
  vector<int> ans;
  ans.push_back(n - 1);
  lst = n - 1;
  int dop = mx;
  while (lst != 0) {
    lst = p[lst][dop];
    ans.push_back(lst);
    dop--;
  }
  reverse(ans.begin(), ans.end());
  cout << mx << '\n';
  for (auto i : ans) {
    cout << i + 1 << " ";
  }
}
