#include <bits/stdc++.h>
using namespace std;
const long long Mx = 5005;
vector<long long> v[Mx], cost[Mx], rev[Mx], rev_cost[Mx];
long long N, M, T;
long long dp[Mx][Mx];
struct dijks {
  long long id, val;
  bool operator<(const dijks &a) const { return val > a.val; }
};
void solve() {
  cin >> N >> M >> T;
  for (long long i = 0; i <= N; i++)
    for (long long j = 0; j <= N; j++) dp[i][j] = 1e17;
  for (long long i = 1; i <= M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    v[a].push_back(b);
    rev[b].push_back(a);
    rev_cost[b].push_back(c);
    cost[a].push_back(c);
  }
  dp[N][0] = 0;
  priority_queue<dijks> q;
  q.push({N, 0});
  while (q.size()) {
    auto ii = q.top();
    q.pop();
    long long i = ii.id;
    for (long long k = 0; k < rev[i].size(); k++) {
      long long vv = rev[i][k], cc = rev_cost[i][k];
      for (long long j = 0; j <= N; j++) {
        if (dp[vv][j + 1] > dp[i][j] + cc) {
          dp[vv][j + 1] = min(dp[vv][j + 1], dp[i][j] + cc);
          q.push({vv, dp[vv][j + 1]});
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= N; i++) {
    if (dp[1][i] <= T) ans = i;
  }
  while (q.size()) q.pop();
  queue<long long> qq;
  qq.push(1);
  cout << ans + 1 << endl;
  while (qq.size()) {
    long long w = qq.front();
    qq.pop();
    if (w == N) {
      cout << w << endl;
      break;
    }
    for (long long i = 0; i < v[w].size(); i++) {
      long long vv = v[w][i], cc = cost[w][i];
      if ((dp[w][ans] - cc) == dp[vv][ans - 1]) {
        cout << w << ' ';
        qq.push(vv);
        break;
      }
    }
    ans--;
  }
}
int32_t main() {
  long long tt;
  tt = 1;
  long long cas = 1;
  while (tt--) {
    solve();
  }
}
