#include <bits/stdc++.h>
using namespace std;
void dfs(const vector<vector<pair<int, int>>> &g, int cur,
         vector<bool> &visited, vector<int> &topo) {
  visited[cur] = true;
  for (pair<int, int> edge : g[cur]) {
    int to = edge.first;
    if (!visited[to]) {
      dfs(g, to, visited, topo);
    }
  }
  topo.push_back(cur);
}
int main() {
  cin.sync_with_stdio(false);
  int n, m, T;
  cin >> n >> m >> T;
  vector<vector<pair<int, int>>> g(n, vector<pair<int, int>>());
  for (int i = 0; i < m; ++i) {
    int from, to, time;
    cin >> from >> to >> time;
    --from, --to;
    g[from].push_back(make_pair(to, time));
  }
  vector<bool> visited(n, false);
  vector<int> topo;
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) dfs(g, i, visited, topo);
  }
  reverse(topo.begin(), topo.end());
  vector<vector<int>> mt(n, vector<int>(n, numeric_limits<int>::max()));
  mt[0][0] = 0;
  vector<vector<int>> prev(n, vector<int>(n, -1));
  prev[0][0] = 0;
  bool started = false;
  for (int node : topo) {
    if (!started && node != 0) continue;
    started = true;
    for (pair<int, int> edge : g[node]) {
      for (int i = 0; i < n; ++i) {
        if (mt[node][i] <= T - edge.second) {
          if (mt[edge.first][i + 1] > mt[node][i] + edge.second) {
            mt[edge.first][i + 1] = mt[node][i] + edge.second;
            prev[edge.first][i + 1] = node;
          }
        }
      }
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    if (mt[n - 1][i] <= T) {
      cout << i + 1 << "\n";
      int cur = n - 1;
      int lastcur = -1;
      int nodes = i;
      vector<int> res;
      while (lastcur != cur) {
        res.push_back(cur + 1);
        lastcur = cur;
        cur = prev[cur][nodes];
        --nodes;
      }
      for (auto it = res.rbegin(); it != res.rend(); ++it) {
        cout << *it << " ";
      }
      return 0;
    }
  }
  return 0;
}
