#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 100;
typedef int LL;
LL deg[maxn], pre[maxn][maxn], dp[maxn][maxn];
vector<pair<LL, LL> > g[maxn];
LL n, m, T;
void topsort() {
  queue<LL> q;
  for (LL i = 1; i <= n; i++) {
    if (deg[i] == 0) q.push(i);
  }
  while (q.size()) {
    LL u = q.front();
    q.pop();
    for (LL i = 0; i < g[u].size(); i++) {
      LL _v = g[u][i].first;
      LL _w = g[u][i].second;
      for (LL j = 2; j <= n; j++) {
        if (dp[u][j - 1] + _w < dp[_v][j]) {
          dp[_v][j] = dp[u][j - 1] + _w;
          pre[_v][j] = u;
        }
      }
      if (--deg[_v] == 0) q.push(_v);
    }
  }
}
int main(void) {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  cin >> n >> m >> T;
  for (LL i = 1; i <= m; i++) {
    LL x, y, w;
    cin >> x >> y >> w;
    g[x].push_back({y, w});
    deg[y]++;
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[1][1] = 0;
  topsort();
  for (LL i = n; i >= 2; i--) {
    if (dp[n][i] <= T) {
      cout << i << endl;
      vector<LL> path;
      for (LL j = i, t = n; j >= 1; j--) {
        path.push_back(t);
        t = pre[t][j];
      }
      for (LL k = path.size() - 1; k >= 0; k--) {
        cout << path[k] << " ";
      }
      cout << endl;
      return 0;
    }
  }
  return 0;
}
