#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 7;
const int M = 100 + 3;
const int inf = 1e9 + 7;
const long long linf = 1e18 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const bool multipleTest = false;
int dp[N][N];
int trace[N][N];
vector<pair<int, int> > adj[N];
int n, m, T;
int deg[N];
deque<int> q;
void solve() {
  cin >> n >> m >> T;
  for (int i = 1; i <= m; ++i) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    adj[u].push_back(make_pair(v, c));
    deg[v]++;
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j) dp[i][j] = inf;
  dp[1][1] = 0;
  trace[1][1] = 0;
  for (int i = 1; i <= n; ++i)
    if (!deg[i]) q.push_back(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop_front();
    for (int j = 0; j < adj[u].size(); ++j) {
      int v = adj[u][j].first;
      int c = adj[u][j].second;
      for (int len = 1; len <= n; ++len) {
        if (dp[v][len] > dp[u][len - 1] + c) {
          dp[v][len] = dp[u][len - 1] + c;
          trace[v][len] = u;
        }
      }
      deg[v]--;
      if (!deg[v]) q.push_back(v);
    }
  }
  pair<int, int> ans = make_pair(0, 0);
  for (int j = 1; j <= n; ++j)
    if (dp[n][j] <= T && j > ans.second) {
      ans = make_pair(n, j);
    }
  vector<int> list;
  cout << ans.second << "\n";
  int r = ans.first;
  int len = ans.second;
  do {
    list.push_back(r);
    r = trace[r][len];
    len--;
  } while (r > 0);
  for (__typeof((list).rbegin()) it = (list).rbegin(); it != (list).rend();
       it++)
    cout << *it << " ";
}
void createTest() {
  freopen("in.txt", "w", stdout);
  cout << 5 << "\n";
  for (int t = 0; t < 5; ++t) {
    cout << 50 << "\n";
    for (int i = 1; i <= 50; ++i) {
      cout << rand() % 100000 << " ";
    }
    puts("");
    cout << 1 << "\n1 2 3\n";
  }
}
int main() {
  int Test = 1;
  if (multipleTest) {
    cin >> Test;
  }
  for (int i = 0; i < Test; ++i) {
    solve();
  }
}
