#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adj[5001];
int dp[5001][5001];
int n, t;
int prnt[5001][5001];
int inf = 1e9 + 5;
void dfs(int p, int node, int len, int cst) {
  if (cst < dp[node][len]) {
    dp[node][len] = cst;
    prnt[node][len] = p;
  } else
    return;
  if (node == n || cst > t) return;
  for (int i = 0; i < adj[node].size(); i++) {
    if (adj[node][i].first == p) continue;
    dfs(node, adj[node][i].first, len + 1, cst + adj[node][i].second);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int m;
  ;
  cin >> n >> m >> t;
  for (int i = 0; i < 5001; i++) {
    for (int j = 0; j < 5001; j++) dp[i][j] = inf;
  }
  int u, v, tst;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> tst;
    adj[u].push_back(make_pair(v, tst));
  }
  dfs(0, 1, 1, 0);
  int maxx = 0;
  for (int i = n; i > 0; i--) {
    if (dp[n][i] <= t) {
      maxx = i;
      break;
    }
  }
  cout << maxx << "\n";
  for (int i = 0; i < n + 1; i++) adj[i].clear();
  stack<int> st;
  int tmp = n;
  while (maxx > 0) {
    st.push(tmp);
    tmp = prnt[tmp][maxx];
    maxx--;
  }
  while (!st.empty()) {
    int u = st.top();
    cout << u << " ";
    st.pop();
  }
  return 0;
}
