#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int M = 5005;
int inf = 1061109567;
struct io_t {
  io_t operator>>(int& first) {
    scanf("%d", &first);
    return *this;
  }
  operator int() {
    int first;
    scanf("%d", &first);
    return first;
  }
  io_t operator>>(long long& first) {
    scanf("%I64d", &first);
    return *this;
  }
} it;
typedef int ds[N];
ds d, z, f[N], p[N];
struct edge {
  edge* s;
  int v, w;
} e[M], *back = e, *h[N];
void add(int u, int v, int w) {
  ++d[v], h[u] = &(*back++ = (edge){h[u], v, w});
}
int n, m, i, j, k, l, u, v, w;
int main() {
  cin >> n >> m >> l;
  while (m--) {
    cin >> u >> v >> w;
    add(u, v, w);
  }
  queue<int> q;
  memset(f, 0x3f, sizeof f);
  f[1][1] = 0;
  for (i = n; i; --i)
    if (!d[i]) q.push(i);
  while (q.size()) {
    u = q.front(), q.pop();
    for (edge* i = h[u]; i; i = i->s) {
      if (!--d[i->v]) q.push(i->v);
      for (j = n; j; --j) {
        w = f[u][j - 1] + i->w;
        if (f[i->v][j] > w) f[i->v][j] = w, p[i->v][j] = u;
      }
    }
  }
  for (i = n; f[n][i] > l; --i)
    ;
  for (j = n; j; j = p[j][i--]) z[++k] = j;
  cout << k << endl;
  while (k) cout << z[k--] << " ";
}
