#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast", "-funroll-all-loops")
using namespace std;
const int N = 5e3 + 10;
int n, m, k, deg[N], dp[N][N], res, pre[N][N];
int head[N], nex[N], to[N], w[N], tot;
inline void add(int a, int b, int c) {
  to[++tot] = b;
  nex[tot] = head[a];
  w[tot] = c;
  head[a] = tot;
}
void Top() {
  queue<int> q;
  dp[1][1] = 0;
  for (int i = 1; i <= n; i++)
    if (!deg[i]) q.push(i);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = nex[i]) {
      if (--deg[to[i]] == 0) q.push(to[i]);
      for (int j = 1; j <= n; j++)
        if (dp[u][j] + w[i] < dp[to[i]][j + 1]) {
          dp[to[i]][j + 1] = dp[u][j] + w[i];
          pre[to[i]][j + 1] = u;
        }
    }
  }
}
void dfs(int x, int y) {
  if (x && y) dfs(pre[x][y], y - 1);
  if (x) printf("%d ", x);
}
signed main() {
  cin >> n >> m >> k;
  memset(dp, 0x3f, sizeof dp);
  for (int i = 1, a, b, c; i <= m; i++)
    cin >> a >> b >> c, add(a, b, c), deg[b]++;
  Top();
  for (int i = 1; i <= n; i++)
    if (dp[n][i] <= k) res = i;
  cout << res << '\n';
  dfs(n, res);
  return 0;
}
