#include <bits/stdc++.h>
using namespace std;
int n, m, t;
deque<pair<int, long long> > graph[5000];
deque<int> order;
bool vis[5000];
map<int, long long> dp[5000];
void toposort(int pos) {
  vis[pos] = true;
  for (int i = 0; i < graph[pos].size(); i++) {
    int v = graph[pos][i].first;
    if (!vis[v]) toposort(v);
  }
  order.push_front(pos);
}
int main() {
  cin >> n >> m >> t;
  for (int i = 0; i < m; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    graph[u - 1].push_back(pair<int, long long>(v - 1, c));
  }
  for (int i = 0; i < n; i++) vis[i] = false;
  for (int i = 0; i < n; i++)
    if (!vis[i]) toposort(i);
  dp[n - 1][1] = 0;
  for (int i = order.size() - 1; i >= 0; i--) {
    int u = order[i];
    for (int j = 0; j < graph[u].size(); j++) {
      pair<int, long long> v = graph[u][j];
      for (auto it = dp[v.first].begin(); it != dp[v.first].end(); it++) {
        long long val = it->second + v.second;
        if (val > t) continue;
        auto it2 = dp[u].find(it->first + 1);
        if (it2 == dp[u].end()) {
          dp[u][it->first + 1] = val;
        } else if (it2->second > val) {
          it2->second = val;
        }
      }
    }
  }
  auto it = dp[0].end();
  it--;
  cout << it->first << endl;
  int pos = 0;
  long long cost = it->second;
  int cnt = it->first;
  deque<int> ans;
  ans.push_back(1);
  while (pos != n - 1) {
    for (int i = 0; i < graph[pos].size(); i++) {
      pair<int, long long> v = graph[pos][i];
      auto it = dp[v.first].find(cnt - 1);
      if (it == dp[v.first].end() || cost != v.second + it->second) continue;
      pos = v.first;
      cost -= v.second;
      cnt--;
      ans.push_back(pos + 1);
      break;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}
