#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
const long long INF = 2000000000;
vector<pair<int, int> > adj[N];
int dp[N][N];
int par[N][N];
vector<int> topol;
bool mark[N];
void dfs(int node) {
  mark[node] = true;
  int other;
  for (int i = 0; i < adj[node].size(); i++) {
    other = adj[node][i].first;
    if (mark[other] == false) {
      dfs(other);
    }
  }
  topol.push_back(node);
}
void print(int node, int len) {
  if (node == 1) return;
  print(par[node][len], len - 1);
  cout << " " << node;
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m, t;
  int x, y, cost;
  cin >> n >> m >> t;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> cost;
    adj[x].push_back(pair<int, int>(y, cost));
  }
  memset(mark, 0, sizeof mark);
  dfs(1);
  reverse(topol.begin(), topol.end());
  memset(par, -1, sizeof par);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = INF;
    }
  }
  dp[1][1] = 0;
  long long temp;
  for (int i = 0; i < topol.size(); i++) {
    x = topol[i];
    for (int len = 1; len < N; len++) {
      if (dp[x][len] != INF) {
        for (int j = 0; j < adj[x].size(); j++) {
          y = adj[x][j].first;
          cost = adj[x][j].second;
          temp = 1ll * dp[x][len] + cost;
          if (temp < INF && dp[y][len + 1] > dp[x][len] + cost) {
            dp[y][len + 1] = dp[x][len] + cost;
            par[y][len + 1] = x;
          }
        }
      }
    }
  }
  for (int len = N - 1; len >= 0; len--) {
    if (dp[n][len] <= t) {
      cout << len << endl;
      cout << 1;
      print(n, len);
      break;
    }
  }
  return 0;
}
