#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[5555];
int dp[5555][5555], L;
int n, m, p[5555][5555];
bool vis[5555];
void dive(int v) {
  for (auto u : g[v]) {
    if (!vis[u.first]) dive(u.first);
    for (__typeof(n) i = (1) - ((1) > (n)); i != (n) - ((1) > (n));
         i += 1 - 2 * ((1) > (n)))
      if (dp[u.first][i] <= L - u.second &&
          dp[u.first][i] < dp[v][i + 1] - u.second) {
        dp[v][i + 1] = dp[u.first][i] + u.second;
        p[v][i + 1] = u.first;
      }
    vis[u.first] = true;
  }
}
int main() {
  cin >> n >> m >> L;
  for (__typeof(n + 1) i = (0) - ((0) > (n + 1));
       i != (n + 1) - ((0) > (n + 1)); i += 1 - 2 * ((0) > (n + 1)))
    for (__typeof(n + 1) j = (0) - ((0) > (n + 1));
         j != (n + 1) - ((0) > (n + 1)); j += 1 - 2 * ((0) > (n + 1)))
      dp[i][j] = L + 1, p[i][j] = -1;
  for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));
       i += 1 - 2 * ((0) > (m))) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u - 1].push_back({v - 1, w});
  }
  dp[n - 1][1] = 0;
  dive(0);
  for (__typeof(2) i = (n + 1) - ((n + 1) > (2)); i != (2) - ((n + 1) > (2));
       i += 1 - 2 * ((n + 1) > (2))) {
    if (dp[0][i] <= L) {
      int cur = 0;
      cout << i << "\n";
      while (cur != -1) {
        cout << cur + 1 << " ";
        cur = p[cur][i--];
      }
      return 0;
    }
  }
}
