#include <bits/stdc++.h>
using namespace std;
const int MaxN = 5e3 + 5;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
struct node {
  int u, v, w;
} G[MaxN];
int f[MaxN][MaxN], res[MaxN];
int dp[MaxN][MaxN];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m, t;
  cin >> n >> m >> t;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    G[i].u = u, G[i].v = v, G[i].w = w;
  }
  memset(dp, INF, sizeof(dp));
  memset(f, 0, sizeof(f));
  dp[1][1] = 0;
  int cnt;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int u = G[j].u, v = G[j].v, w = G[j].w;
      if (dp[i][v] > dp[i - 1][u] + w) {
        dp[i][v] = dp[i - 1][u] + w;
        f[i][v] = u;
      }
    }
    if (dp[i][n] <= t) cnt = i;
  }
  cout << cnt << endl;
  int cur = n, num = 0;
  while (cur) {
    res[++num] = cur;
    ;
    cur = f[cnt--][cur];
  }
  for (int i = num; i > 0; i--) cout << res[i] << " ";
  cout << endl;
  return 0;
}
