#include <bits/stdc++.h>
const int maxn = 5050;
using namespace std;
struct Edge {
  int to, dis, next;
} e[maxn];
int n, m, t, cnt = 0, x, y, z, ans;
int head[maxn], rd[maxn];
int f[maxn][maxn];
int pre[maxn][maxn];
vector<int> s;
queue<int> q;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * f;
}
inline void add(int x, int y, int z) {
  e[++cnt].dis = z;
  e[cnt].to = y;
  e[cnt].next = head[x];
  head[x] = cnt;
}
int main() {
  memset(f, 0x3f3f3f3f, sizeof(f));
  memset(pre, -1, sizeof(pre));
  memset(head, -1, sizeof(head));
  memset(rd, 0, sizeof(rd));
  n = read(), m = read(), t = read();
  for (int i = 1; i <= m; i++) {
    x = read(), y = read(), z = read();
    add(x, y, z);
    rd[y]++;
  }
  for (int i = 1; i <= n; i++) {
    if (rd[i] == 0) q.push(i);
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    s.push_back(x);
    for (int i = head[x]; i != -1; i = e[i].next)
      if ((--rd[e[i].to]) == 0) q.push(e[i].to);
  }
  f[1][1] = 0;
  for (int k = 0; k < s.size(); k++) {
    int u = s[k];
    for (int i = head[u]; i != -1; i = e[i].next) {
      int v = e[i].to;
      for (int j = 2; j <= n; j++) {
        if (f[v][j] > f[u][j - 1] + e[i].dis) {
          f[v][j] = f[u][j - 1] + e[i].dis;
          pre[v][j] = u;
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (f[n][i] <= t) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  int path[maxn];
  int num = 0, pos = n;
  while (pos != -1) {
    path[++num] = pos;
    pos = pre[pos][ans];
    ans--;
  }
  for (int i = num; i >= 1; i--) {
    printf("%d ", path[i]);
  }
  return 0;
}
