#include <bits/stdc++.h>
using namespace std;
int n, m, t, head[5005], cnt, dp[5005][5005], pre[5005][5005], d[5005],
    path[5005];
struct node {
  int to;
  int next;
  int w;
} edge[5005];
void add(int x, int y, int z) {
  edge[cnt].to = y;
  edge[cnt].next = head[x];
  edge[cnt].w = z;
  head[x] = cnt++;
}
queue<int> q;
void bfs() {
  dp[1][1] = 0;
  bool visit[5005];
  for (int i = 1; i <= n; i++) {
    if (!d[i]) {
      visit[i] = true;
      q.push(i);
    }
  }
  while (!q.empty()) {
    int top = q.front();
    q.pop();
    for (int i = head[top]; i != -1; i = edge[i].next) {
      int v = edge[i].to;
      if (d[v]) {
        d[v]--;
        for (int j = 2; j <= n; j++) {
          if (dp[v][j] > dp[top][j - 1] + edge[i].w) {
            dp[v][j] = dp[top][j - 1] + edge[i].w;
            pre[v][j] = top;
          }
        }
      }
      if (!d[v]) q.push(v);
    }
  }
}
int main() {
  int a, b, c, max1 = 0, num = 0, x;
  memset(head, -1, sizeof(head));
  cnt = 0;
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    add(a, b, c);
    d[b]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = 0x3f3f3f3f;
    }
  }
  bfs();
  for (int i = n; i >= 1; i--) {
    if (dp[n][i] <= t) {
      max1 = i;
      break;
    }
  }
  printf("%d\n", max1);
  x = n;
  while (x != 1) {
    path[++num] = x;
    x = pre[x][max1];
    max1--;
  }
  path[++num] = 1;
  for (int i = num; i >= 1; i--) printf("%d ", path[i]);
  return 0;
}
