#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, T;
  cin >> n >> m >> T;
  vector<vector<int> > dp(n + 1, vector<int>(n + 1, -1));
  vector<pair<int, int> > rg[n + 1];
  vector<vector<int> > par(n + 1, vector<int>(n + 1, -1));
  while (m--) {
    int u, v, t;
    cin >> u >> v >> t;
    rg[v].push_back({u, t});
  }
  dp[1][1] = 0;
  function<long long(int, int)> go = [&](int u, int no) {
    if (u == 1 and no > 1) return (int)2e9;
    if (no < 0) return (int)2e9;
    if (dp[u][no] != -1) return dp[u][no];
    dp[u][no] = (long long)1e9 + 1;
    for (auto it : rg[u]) {
      long long ret = go(it.first, no - 1) + it.second;
      if (ret < dp[u][no]) {
        par[u][no] = it.first;
        dp[u][no] = ret;
      }
    }
    return dp[u][no];
  };
  par[1][1] = 1;
  for (int i = n; i >= 1; i--) {
    if (go(n, i) <= T) {
      int v = n;
      int j = i;
      vector<int> ans;
      while (par[v][j] != v) {
        ans.push_back(v);
        v = par[v][j];
        j--;
      }
      ans.push_back(v);
      reverse(ans.begin(), ans.end());
      cout << ans.size() << endl;
      for (int it : ans) cout << it << " ";
      break;
    }
  }
  return 0;
}
