#include <bits/stdc++.h>
using namespace std;
struct edge {
  int next, v, w;
} e[10010];
const long long INF = (1ll << 62);
int n, m, cnt, t;
int head[5050];
short way[5050][5050];
long long dp[5050][5050];
bool v[5050];
void addEdge(int x, int y, int z) {
  e[++cnt].v = y;
  e[cnt].next = head[x];
  e[cnt].w = z;
  head[x] = cnt;
}
void dfs(int x) {
  v[x] = 1;
  for (int i = head[x]; i != -1; i = e[i].next) {
    int y = e[i].v;
    int z = e[i].w;
    if (!v[y]) dfs(y);
    for (int j = 1; j <= n - 1; j++) {
      if (dp[y][j] + z < dp[x][j + 1]) {
        dp[x][j + 1] = dp[y][j] + z;
        way[x][j + 1] = y;
      }
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &t);
  memset(head, -1, sizeof(head));
  memset(way, 0, sizeof(way));
  memset(v, 0, sizeof(v));
  cnt = 0;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    addEdge(x, y, z);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = INF;
    }
  }
  dp[n][1] = 0;
  dfs(1);
  int i = n;
  for (; dp[1][i] > t; i--)
    ;
  printf("%d\n", i);
  printf("%d", 1);
  for (int j = 1; way[j][i]; i--) {
    printf(" %d", j = way[j][i]);
  }
  puts("");
  return 0;
}
