#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, m, d;
int f[5005][5005], pre[5005][5005], mx;
int ee, h[5005], nex[5005], to[5005], val[5005];
int rdu[5005];
vector<int> s;
stack<int> path;
void addedge(int x, int y, int z) {
  nex[++ee] = h[x];
  to[ee] = y;
  val[ee] = z;
  h[x] = ee;
}
void topo() {
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (rdu[i] == 0) q.push(i);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    s.push_back(x);
    for (int i = h[x]; i; i = nex[i])
      if ((--rdu[to[i]]) == 0) q.push(to[i]);
  }
}
signed main() {
  memset(f, INF, sizeof(f));
  memset(pre, -1, sizeof(pre));
  cin >> n >> m >> d;
  for (int i = 1, x, y, z; i <= m && cin >> x >> y >> z; i++) {
    addedge(x, y, z);
    rdu[y]++;
  }
  topo();
  f[1][1] = 0;
  for (int k = 0; k < s.size(); k++) {
    int x = s[k];
    for (int i = h[x]; i; i = nex[i])
      for (int j = 2; j <= n; j++)
        if (f[x][j - 1] + val[i] < f[to[i]][j]) {
          f[to[i]][j] = f[x][j - 1] + val[i];
          pre[to[i]][j] = x;
        }
  }
  for (int i = n; i >= 1; i--)
    if (f[n][i] <= d) {
      mx = i;
      break;
    }
  cout << mx << endl;
  int pos = n, dep = mx;
  while (pos != -1) {
    path.push(pos);
    pos = pre[pos][dep];
    dep--;
  }
  while (!path.empty()) {
    cout << path.top() << ' ';
    path.pop();
  }
  cout << endl;
  return 0;
}
