#include <bits/stdc++.h>
using namespace std;
using ll = int;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
const ll oo = (INT_MAX / 2) - 5;
const double eps = 1e-9;
vector<vector<pll>> adj;
int indeg[5005];
vl sorted;
int N = 0;
bool top_sort() {
  fill_n(indeg, N, 0);
  for (ll i = (0); i < (N); i++)
    for (ll j = (0); j < (ll((adj[i]).size())); j++) indeg[adj[i][j].first]++;
  stack<int> zero;
  for (ll i = (0); i < (N); i++)
    if (indeg[i] == 0) zero.push(i);
  sorted.clear();
  while (!zero.empty()) {
    int n = zero.top();
    zero.pop();
    sorted.push_back(n);
    for (ll i = (0); i < (ll((adj[n]).size())); i++) {
      if (--indeg[adj[n][i].first] == 0) zero.push(adj[n][i].first);
    }
  }
  return ll((sorted).size()) == N;
}
int main() {
  cin.sync_with_stdio(0);
  int n, m, T;
  cin >> n >> m >> T;
  N = n;
  adj.resize(n);
  for (ll i = (0); i < (m); i++) {
    int a, b, cost;
    cin >> a >> b >> cost;
    a--;
    b--;
    adj[a].push_back({b, cost});
  }
  top_sort();
  vvl dp(n + 5, vl(n + 5, oo)), orig(n + 5, vl(n + 5, -1));
  dp[0][1] = 0;
  for (long node : sorted) {
    for (auto o : adj[node]) {
      int b = o.first, cost = o.second;
      for (ll i = (0); i < (n + 1); i++) {
        if (dp[node][i] != oo) {
          ll other_cost = dp[b][i + 1];
          ll new_cost = dp[node][i] + cost;
          if (new_cost < other_cost) {
            dp[b][i + 1] = new_cost;
            orig[b][i + 1] = node;
          }
        }
      }
    }
  }
  int num = 0;
  for (ll i = (0); i < (n + 1); i++) {
    if (dp[n - 1][i] <= T) {
      num = i;
    }
  }
  cout << num << endl;
  vl route;
  int cur = n - 1;
  while (cur != -1) {
    route.push_back(cur);
    cur = orig[cur][num--];
  }
  reverse(begin(route), end(route));
  for (ll i = (0); i < (ll((route).size())); i++) {
    cout << (route[i] + 1);
    if (i != ll((route).size()) - 1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}
