#include <bits/stdc++.h>
using namespace std;
const long long int M = 5e3 + 7;
const long long int mod = 1e9 + 7;
const long long int infi = -1e15 + 7;
long long int dp[M][M];
vector<pair<long long int, long long int> > v[M], vr[M];
long long int dfs(long long int curr, long long int ans) {
  if (curr == 1) {
    return 0;
  }
  for (auto k : vr[curr]) {
    if (dp[k.first][ans - 1] + k.second == dp[curr][ans]) {
      curr = k.first;
      dfs(curr, ans - 1);
      cout << curr << ' ';
      return 0;
    }
  }
}
int main() {
  long long int n, m, T;
  scanf("%lld %lld %lld", &n, &m, &T);
  long long int i, j, t;
  for (i = 0; i < n + 1; i++) {
    for (j = 0; j < n + 1; j++) dp[i][j] = infi;
  }
  long long int a, b, w;
  for (i = 0; i < m; i++) {
    scanf("%lld %lld %lld", &a, &b, &w);
    v[a].push_back({b, w});
    vr[b].push_back({a, w});
  }
  dp[1][1] = 0;
  priority_queue<pair<long long int, long long int> > pq;
  pq.push({1, 1});
  long long int node, value;
  while (!pq.empty()) {
    node = pq.top().second;
    value = pq.top().first;
    pq.pop();
    if (dp[node][value] > T) continue;
    for (auto k : v[node]) {
      if (dp[k.first][value + 1] == infi) {
        dp[k.first][value + 1] = dp[node][value] + k.second;
        pq.push({value + 1, k.first});
      } else if (dp[k.first][value + 1] > dp[node][value] + k.second) {
        dp[k.first][value + 1] = dp[node][value] + k.second;
        pq.push({value + 1, k.first});
      }
    }
  }
  long long int ans = infi;
  for (i = 0; i < n + 1; i++) {
    if (dp[n][i] != infi && dp[n][i] <= T) ans = i;
  }
  cout << ans << endl;
  long long int curr = n;
  dfs(n, ans);
  cout << n << endl;
  return 0;
}
