#include <bits/stdc++.h>
using namespace std;
const int maxN = 5005, oo = 1e9 + 7;
int n, m, limit, u[maxN], v[maxN], t[maxN], par[maxN][maxN], dp[maxN][maxN],
    x[maxN], pos;
int main() {
  cin >> n >> m >> limit;
  for (int i = 1; i <= m; i++) {
    cin >> u[i] >> v[i] >> t[i];
  }
  fill_n(&dp[0][0], sizeof(dp) / sizeof(dp[0][0]), oo);
  dp[1][1] = 0;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (dp[i - 1][u[j]] + t[j] < dp[i][v[j]]) {
        dp[i][v[j]] = dp[i - 1][u[j]] + t[j];
        par[i][v[j]] = u[j];
      }
    if (dp[i][n] <= limit) pos = i;
  }
  cout << pos << endl;
  int id = n;
  for (int i = pos; i >= 1; i--) {
    x[i] = id;
    id = par[i][id];
  }
  for (int i = 1; i <= pos; i++) cout << x[i] << " ";
}
