#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000 + 100;
struct Edge {
  int from, to, w, next;
} edge[MAXN];
int tol;
int n, m, t;
int head[MAXN];
void addedge(int u, int v, int w) {
  edge[tol].from = u, edge[tol].to = v, edge[tol].w = w,
  edge[tol].next = head[u], head[u] = tol++;
}
int d[MAXN][MAXN], pre[MAXN][MAXN];
void print(int i, int u) {
  if (i == 1) {
    printf("1 ");
    return;
  }
  print(i - 1, pre[i][u]);
  printf("%d%c", u, u == n ? '\n' : ' ');
}
void spfa() {
  int inq[MAXN];
  memset(inq, 0, sizeof(inq));
  queue<pair<int, int> > q;
  d[1][1] = 0;
  q.push(make_pair(1, 1));
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    q.pop();
    int u = cur.first, f = cur.second;
    for (int i = head[u]; i != -1; i = edge[i].next) {
      int v = edge[i].to;
      if (d[f + 1][v] > d[f][u] + edge[i].w) {
        d[f + 1][v] = d[f][u] + edge[i].w;
        pre[f + 1][v] = u;
        q.push(make_pair(v, f + 1));
      }
    }
  }
}
int main() {
  memset(d, 0x3f, sizeof(d));
  memset(pre, -1, sizeof(pre));
  tol = 0;
  memset(head, -1, sizeof(head));
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    addedge(u, v, w);
  }
  spfa();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (d[i][n] <= t) ans = max(ans, i);
  }
  printf("%d\n", ans);
  print(ans, n);
  return 0;
}
