#include <bits/stdc++.h>
using namespace std;
const int maxn = 5010;
int u[maxn], v[maxn], w[maxn], parent[maxn][maxn], x[maxn], dp[maxn][maxn];
int main() {
  int n, m, T;
  cin >> n >> m >> T;
  for (int i = 0; i < m; i++) {
    cin >> u[i] >> v[i] >> w[i];
  }
  int length = 0;
  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][v[j]] > dp[i - 1][u[j]] + w[j]) {
        dp[i][v[j]] = dp[i - 1][u[j]] + w[j];
        parent[i][v[j]] = u[j];
      }
    }
    if (dp[i][n] <= T) length = i;
  }
  int id = n;
  x[length] = n;
  for (int i = length - 1; i > 0; i--) {
    x[i] = parent[i + 1][id];
    id = x[i];
  }
  cout << length << endl;
  for (int i = 1; i <= length; i++) {
    cout << x[i] << " ";
  }
  cout << endl;
  return 0;
}
