#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a[5001];
int n, t;
int main() {
  int m, u, v, w;
  cin >> n >> m >> t;
  vector<vector<int> > f(n + 1, vector<int>(2, 0));
  vector<vector<int> > p(n + 1, vector<int>(2, 2e9 + 1));
  vector<vector<int> > track(n + 1, vector<int>(n + 1, 0));
  for (int i = 1; i <= m; i++) {
    cin >> u >> v >> w;
    a[v].push_back(make_pair(u, w));
  }
  f[1][0] = 1;
  p[1][0] = 0;
  int id = 1;
  int res = 0;
  for (int j = 2; j <= n; j++) {
    for (int i = 2; i <= n; i++)
      for (int k = 0; k < a[i].size(); k++) {
        v = a[i][k].first;
        w = a[i][k].second;
        if (f[v][1 - id] &&
            ((f[i][id] < f[v][1 - id] + 1 && p[v][1 - id] + w <= t) ||
             (f[i][id] == f[v][1 - id] + 1 && p[v][1 - id] + w < p[i][id]))) {
          f[i][id] = f[v][1 - id] + 1;
          p[i][id] = p[v][1 - id] + w;
          track[i][j] = v;
          if (i == n) res = max(res, j);
        }
      }
    id ^= 1;
  }
  vector<int> road;
  cout << res << endl;
  u = n;
  do {
    u = track[u][res--];
    road.push_back(u);
  } while (u > 1);
  for (int i = road.size() - 1; i >= 0; i--) cout << road[i] << ' ';
  cout << n;
}
