#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, m;
vector<vector<pair<int, long long>>> gr;
vector<bool> visited;
vector<int> ts;
void dfs(int v) {
  visited[v] = true;
  for (auto u : gr[v]) {
    if (!visited[u.first]) dfs(u.first);
  }
  ts.push_back(v);
}
void topological_sort() {
  ts.clear();
  for (int i = 1; i <= n; ++i) {
    if (!visited[i]) {
      dfs(i);
    }
  }
  reverse(ts.begin(), ts.end());
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> n >> m >> t;
  gr.resize(n + 1);
  visited.resize(n + 1);
  for (int i = 0; i < m; i++) {
    int x, y;
    long long w;
    cin >> x >> y >> w;
    pair<int, long long> p = {y, w};
    gr[x].push_back(p);
  }
  topological_sort();
  vector<vector<int>> dp(n + 1, vector<int>(n + 1, MOD));
  vector<vector<int>> next(n + 1, vector<int>(n + 1));
  while (ts.back() != n) {
    ts.pop_back();
  }
  reverse(ts.begin(), ts.end());
  dp[n][1] = 0;
  for (int i : ts) {
    for (auto p : gr[i]) {
      for (int j = 2; j <= n; j++) {
        if (dp[p.first][j - 1] + p.second < dp[i][j]) {
          dp[i][j] = dp[p.first][j - 1] + p.second;
          next[i][j] = p.first;
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (dp[1][i] <= t) {
      int cur = 1;
      cout << i << '\n';
      while (cur) {
        cout << cur << ' ';
        cur = next[cur][i--];
      }
      return 0;
    }
  }
  return 0;
}
