#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
const int INF = 1e9 + 7;
int n, m, t, dp[N][N], pr[N][N];
vector<pair<int, int>> edge[N];
int calc(int i, int j) {
  if (j < 0) {
    return INF;
  }
  if (dp[i][j] == -1) {
    dp[i][j] = INF;
    for (pair<int, int> k : edge[i]) {
      int w = k.first, to = k.second;
      if (calc(to, j - 1) + w < dp[i][j]) {
        dp[i][j] = calc(to, j - 1) + w;
        pr[i][j] = to;
      }
    }
  }
  return dp[i][j];
}
void cout_pr(int i, int j) {
  if (pr[i][j] != 0) {
    cout_pr(pr[i][j], j - 1);
  }
  cout << i << ' ';
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> t;
  for (int from, to, w, i = 0; i < m; ++i) {
    cin >> from >> to >> w;
    edge[to].push_back(make_pair(w, from));
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = -1;
    }
  }
  dp[1][1] = 0;
  int ans = n;
  while (calc(n, ans) > t) {
    ans--;
  }
  cout << ans << "\n";
  cout_pr(n, ans);
  return 0;
}
