#include <bits/stdc++.h>
using namespace std;
int d[5005][5005], pre[5005][5005];
vector<pair<int, int> > v[5005];
int n, m, tot;
void solve(int src, int par, int t, int r) {
  if (t >= d[src][r]) return;
  d[src][r] = t;
  pre[src][r] = par;
  for (auto x : v[src]) {
    solve(x.first, src, t + x.second, r + 1);
  }
}
void fun(int src, int num) {
  if (num == 0) return;
  fun(pre[src][num], num - 1);
  cout << src << " ";
}
signed main() {
  cin >> n >> m >> tot;
  for (int i = 0; i < m; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    v[x].push_back(make_pair(y, t));
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) d[i][j] = tot + 1;
  }
  solve(1, 1, 0, 1);
  for (int i = n; i >= 1; i--) {
    if (d[n][i] <= tot) {
      cout << i << endl;
      fun(n, i);
      return 0;
    }
  }
}
