#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int u[maxn], v[maxn], w[maxn], dp[maxn][maxn], parent[maxn][maxn], x[maxn];
int main() {
  int n, m, t, pos;
  cin >> n >> m >> t;
  for (int i = 0; i < m; i++) {
    cin >> u[i] >> v[i] >> w[i];
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[1][1] = 0;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (dp[i - 1][u[j]] + w[j] < dp[i][v[j]]) {
        dp[i][v[j]] = dp[i - 1][u[j]] + w[j];
        parent[i][v[j]] = u[j];
      }
    }
    if (dp[i][n] <= t) pos = i;
  }
  int id = n;
  for (int i = pos; i >= 1; i--) {
    x[i] = id;
    id = parent[i][id];
  }
  cout << pos << endl;
  for (int i = 1; i <= pos; i++) cout << x[i] << " ";
  return 0;
}
