#include <bits/stdc++.h>
int dp[5005][5005];
int last[5005][5005];
struct edge {
  int to, next, c;
} edges[5005];
int head[5005];
int tot;
int indgr[5005];
void addedge(int from, int to, int c) {
  edges[tot].to = to;
  edges[tot].c = c;
  edges[tot].next = head[from];
  head[from] = tot;
  tot++;
}
int stk[5005];
bool vis[5005];
void init() {
  tot = 1;
  memset(vis, 0, sizeof(vis));
  memset(head, 0, sizeof(head));
}
int main() {
  init();
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int i;
  memset(dp, 0x3f, sizeof(dp));
  dp[1][1] = 0;
  for (i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    addedge(a, b, c);
    indgr[b]++;
  }
  int gg = n + 1;
  while (gg--) {
    for (i = 1; i <= n; i++) {
      if (!vis[i] && indgr[i] == 0) {
        vis[i] = true;
        int j;
        for (j = head[i]; j; j = edges[j].next) {
          int v = edges[j].to;
          indgr[v]--;
          int k;
          for (k = 1; k <= n; k++) {
            if (dp[v][k + 1] > dp[i][k] + edges[j].c) {
              dp[v][k + 1] = dp[i][k] + edges[j].c;
              last[v][k + 1] = i;
            }
          }
        }
        break;
      }
    }
  }
  int ans = 0;
  for (i = n; i >= 1; i--) {
    if (dp[n][i] == 0x3f3f3f3f) continue;
    if (dp[n][i] <= k) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  int stktop = 0;
  int now = n;
  int left = ans;
  while (true) {
    stk[stktop++] = now;
    if (now == 1) break;
    now = last[now][left];
    left--;
  }
  for (i = stktop - 1; i >= 0; i--) {
    printf("%d ", stk[i]);
  }
}
