#include <bits/stdc++.h>
using namespace std;
const int dd = (int)5e3 + 7;
const int INF = (int)1e9 + 7;
void file() {}
vector<pair<int, int> > Gr[dd];
int dp[dd][dd], n, p[dd][dd], used[dd];
void get(int v) {
  used[v] = 1;
  for (int i = 0; i < (int)Gr[v].size(); ++i) {
    int to = Gr[v][i].first;
    if (!used[to]) {
      get(to);
    }
  }
  for (int i = 0; i < (int)Gr[v].size(); ++i) {
    int dist = Gr[v][i].second, to = Gr[v][i].first;
    for (int k = 1; k <= n; ++k) {
      if (dp[v][k] > dp[to][k - 1] + dist) {
        dp[v][k] = dp[to][k - 1] + dist;
        p[v][k] = to;
      }
    }
  }
}
int main() {
  file();
  int m, T;
  scanf("%d%d%d", &n, &m, &T);
  for (int i = 0; i < m; ++i) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    Gr[y - 1].push_back({x - 1, w});
  }
  for (int i = 0; i < n; ++i) {
    fill(dp[i], dp[i] + dd, INF);
  }
  dp[0][1] = 0;
  get(n - 1);
  int ans = 0;
  for (int i = 2; i <= n; ++i) {
    if (dp[n - 1][i] <= T) {
      ans = i;
    }
  }
  printf("%d\n", ans);
  int V = n - 1;
  vector<int> C;
  while (V != 0) {
    C.push_back(V);
    V = p[V][ans];
    --ans;
  };
  C.push_back(0);
  reverse(C.begin(), C.end());
  for (auto i : C) {
    printf("%d ", i + 1);
  }
  return 0;
}
