#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int maxN = 5010;
int n, m, T;
vector<pair<int, int>> g[maxN];
int dp[maxN][maxN], pr[maxN][maxN];
signed main() {
  cin >> n >> m >> T;
  for (int i = 0; i < m; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    g[a].push_back({b, w});
  }
  for (int i = 0; i < maxN; i++) {
    for (int j = 0; j < maxN; j++) {
      dp[i][j] = 2e9;
      pr[i][j] = -1;
    }
  }
  dp[0][1] = 0;
  for (int now = 1; now <= n - 1; now++) {
    for (int i = 0; i < n; i++) {
      for (auto t : g[i]) {
        int to = t.first, w = t.second;
        long long int pp = dp[i][now];
        pp += w;
        if (pp > T) continue;
        if (dp[to][now + 1] > dp[i][now] + w) {
          dp[to][now + 1] = dp[i][now] + w;
          pr[to][now + 1] = i;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dp[n - 1][i] <= T) ans = i;
  }
  vector<int> path;
  int now = n - 1;
  while (now > -1) {
    path.push_back(now);
    now = pr[now][ans];
    ans--;
  }
  reverse(path.begin(), path.end());
  cout << path.size() << "\n";
  for (auto i : path) cout << i + 1 << " ";
  return 0;
}
