#include <bits/stdc++.h>
using namespace std;
int n, m, T;
int k(-1);
vector<int> topo;
vector<vector<pair<int, int>>> graph;
int par[5020][5020];
bool visit[5020];
int cache[5020][5020];
void dfs(int v) {
  if (visit[v]) return;
  visit[v] = true;
  for (int i = 0; i < graph[v].size(); i++) {
    dfs(graph[v][i].first);
  }
  topo.push_back(v);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> T;
  graph.resize(n);
  while (m--) {
    int u, v, t;
    cin >> u >> v >> t;
    u--;
    v--;
    graph[u].push_back(make_pair(v, t));
  }
  for (long long i = (0); i <= ((long long)(n + 1) - 1); i++) {
    for (long long j = (0); j <= ((long long)(n + 1) - 1); j++) {
      cache[i][j] = INT_MAX;
      par[i][j] = -1;
    }
  }
  cache[0][1] = 0;
  dfs(0);
  reverse(topo.begin(), topo.end());
  for (int i = 0; i < topo.size(); i++) {
    int v = topo[i];
    for (int j = 0; j < n; j++) {
      if (cache[v][j] >= T) continue;
      for (int k = 0; k < (int)graph[v].size(); ++k) {
        int to = graph[v][k].first;
        int cost = min(INT_MAX, cache[v][j] + graph[v][k].second);
        if (cache[to][j + 1] > cost) {
          cache[to][j + 1] = cost;
          par[to][j + 1] = v;
        }
      }
    }
  }
  vector<int> ans;
  int v = n - 1;
  int cnt = 0;
  for (int i = n; i >= 0; --i) {
    if (cache[v][i] <= T) {
      cnt = i;
      break;
    }
  }
  while (v != -1) {
    ans.push_back(v);
    v = par[v][cnt];
    --cnt;
  }
  cout << int(ans.size()) << '\n';
  for (int i = (int)ans.size() - 1; i >= 0; --i) cout << ans[i] + 1 << " ";
}
