#include <bits/stdc++.h>
using namespace std;
long long n, m, t;
vector<vector<pair<int, int>>> g(5005);
int dp[5005][5005];
int pare[5005][5005];
long long solve(long long x, long long y) {
  if (x == n) {
    if (y == 1)
      return 0;
    else
      return 1000000007;
  }
  if (y <= 0) return 1000000007;
  int &ans = dp[x][y];
  if (ans != -1) return ans;
  ans = 1000000007;
  for (auto X : g[x]) {
    int t1 = solve(X.first, y - 1);
    if (t1 + X.second < ans) {
      ans = t1 + X.second;
      pare[x][y] = X.first;
    }
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> t;
  while (m--) {
    long long x, y, w;
    cin >> x >> y >> w;
    g[x].push_back({y, w});
  }
  long long ind;
  memset(dp, -1, sizeof(dp));
  for (int i = n; i >= 1; i--) {
    long long tt = solve(1, i);
    if (tt <= t) {
      ind = i;
      break;
    }
  }
  cout << ind << "\n";
  vector<long long> ans;
  long long tt = 1;
  while (tt != n) {
    ans.push_back(tt);
    tt = pare[tt][ind];
    ind--;
  }
  ans.push_back(n);
  for (auto X : ans) cout << X << " ";
  cout << "\n";
}
