#include <bits/stdc++.h>
using ll = long long;
const int size = 5001;
int n, m, T;
int dp[size][size];
int toGo[size][size];
std::vector<std::pair<int, int>> graph[size];
int calc(int vertex, int nVertices) {
  if (dp[vertex][nVertices] != -1) {
    return dp[vertex][nVertices];
  }
  dp[vertex][nVertices] = std::numeric_limits<int>::max();
  for (const auto& p : graph[vertex]) {
    ll ret = p.second * 1ll + calc(p.first, nVertices - 1);
    if (ret < dp[vertex][nVertices]) {
      dp[vertex][nVertices] = ret;
      toGo[vertex][nVertices] = p.first;
    }
  }
  return dp[vertex][nVertices];
}
int main() {
  memset(dp, -1, sizeof(dp));
  std::cin >> n >> m >> T;
  for (int i = 0; i < m; ++i) {
    int u, v, t;
    std::cin >> u >> v >> t;
    graph[v].push_back({u, t});
  }
  dp[1][1] = 0;
  int i = n;
  for (; i > 0; --i) {
    ll ans = calc(n, i);
    if (ans <= T) {
      std::cout << i << '\n';
      break;
    }
  }
  int vertex = n;
  std::vector<int> ans;
  while (true) {
    ans.push_back(vertex);
    vertex = toGo[vertex][i];
    --i;
    if (i < 1) break;
  }
  std::cout << ans.back();
  for (int i = ans.size() - 2; i >= 0; --i) std::cout << ' ' << ans[i];
  std::cout << '\n';
  return 0;
}
