#include <bits/stdc++.h>
using namespace std;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
const int N = 5e3 + 9;
long long mem[N][N], in[N];
vector<pair<int, int> > adjL[N], rev[N];
vector<int> show;
void dfs(int u) {
  for (auto& v : adjL[u]) {
    in[v.first]++;
    if (in[v.first] == 1) dfs(v.first);
  }
}
void Build(int u, int edges, long long rem) {
  if (!edges) {
    show.push_back(1);
    return;
  }
  for (auto& v : rev[u]) {
    if (mem[v.first][edges - 1] + v.second == rem) {
      Build(v.first, edges - 1, rem - v.second);
      show.push_back(u);
      return;
    }
  }
}
int main() {
  file();
  fast();
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) mem[i][j] = 1e14;
  int n, m, have;
  cin >> n >> m >> have;
  while (m--) {
    int u, v, t;
    cin >> u >> v >> t;
    adjL[u].push_back({v, t});
    rev[v].push_back({u, t});
  }
  dfs(1);
  queue<int> q;
  mem[1][0] = 0;
  q.push(1);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (auto& v : adjL[cur]) {
      for (int i = 0; i < n; i++) {
        mem[v.first][i + 1] = min(mem[v.first][i + 1], mem[cur][i] + v.second);
      }
      in[v.first]--;
      if (!in[v.first]) q.push(v.first);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mem[n][i] <= have) ans = i;
  }
  Build(n, ans, mem[n][ans]);
  cout << (int)(show.size()) << "\n";
  for (auto& it : show) cout << it << ' ';
  cout << "\n";
  return 0;
}
