#include <bits/stdc++.h>
using namespace std;
int dp[5007][5007];
int ans[5007][5007];
vector<vector<pair<int, int>>> edges;
int n, m, T;
void relax(int v) {
  for (int i = 0; i < n; ++i)
    if (dp[v][i] != -1) return;
  for (pair<int, int> i : edges[v]) {
    relax(i.first);
    for (int k = 1; k < n; ++k) {
      int neu = dp[i.first][k - 1] + i.second;
      if (dp[i.first][k - 1] != -1 && (neu < dp[v][k] || dp[v][k] == -1) &&
          neu <= T) {
        dp[v][k] = neu;
        ans[v][k] = i.first;
      }
    }
  }
}
int main() {
  cin >> n >> m >> T;
  edges.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b, t;
    cin >> a >> b >> t;
    edges[b - 1].emplace_back(a - 1, t);
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) dp[i][j] = -1;
  dp[0][0] = 0;
  relax(n - 1);
  for (int i = n - 1; i >= 0; --i) {
    if (dp[n - 1][i] <= T && dp[n - 1][i] != -1) {
      vector<int> path = {n - 1};
      while (path.back() != 0)
        path.push_back(ans[path.back()][i + 1 - path.size()]);
      cout << path.size() << endl;
      for (int j = path.size() - 1; j >= 0; --j) cout << (path[j] + 1) << " ";
      break;
    }
  }
  return 0;
}
