#include <bits/stdc++.h>
using namespace std;
int N, M, T;
vector<pair<int, int> > Gt[5005];
int DP[5005][5005];
int daddy[5005][5005];
int used[5005];
void DFS(int k) {
  used[k] = 1;
  for (auto it : Gt[k])
    if (!used[it.first]) DFS(it.first);
  for (auto it : Gt[k])
    for (int j = 2; j <= N; ++j)
      if (DP[k][j] > DP[it.first][j - 1] + it.second) {
        DP[k][j] = DP[it.first][j - 1] + it.second;
        daddy[k][j] = it.first;
      }
}
int main() {
  cin >> N >> M >> T;
  for (int i = 1; i <= M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    Gt[b].push_back({a, c});
  }
  for (int i = 0; i < 5005; ++i)
    for (int j = 0; j < 5005; ++j) DP[i][j] = (1LL << 30);
  DP[1][1] = 0;
  DFS(N);
  int best = 0;
  for (int i = N; i >= 1; --i)
    if (DP[N][i] <= T) {
      best = i;
      break;
    }
  cout << best << "\n";
  int crt = N;
  int xnou, ynou;
  int lg = best;
  vector<int> sol;
  for (int i = 1; i <= lg; ++i) {
    sol.push_back(crt);
    xnou = daddy[crt][best];
    crt = xnou;
    best = lg - i;
  }
  reverse(sol.begin(), sol.end());
  for (auto it : sol) cout << it << " ";
  return 0;
}
