#include <bits/stdc++.h>
using namespace std;
struct node {
  int to;
  int next;
  long long c;
} w[5005];
int T;
int cnt = 0, n, m;
int h[5005];
int p[5005][5005];
int in[5005];
int q[5005], qq[5005];
bool vis[5005];
int Dis[5005][5000];
int ans = 0;
void AddEdge(int x, int y, long long z) {
  cnt++;
  w[cnt].to = y;
  w[cnt].next = h[x];
  w[cnt].c = z;
  h[x] = cnt;
}
void Topo() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) Dis[i][j] = 1 << 30;
  Dis[1][1] = 0;
  q[1] = 1;
  int head = 0;
  int tail = 1;
  while (head < tail) {
    head++;
    int x = q[head];
    for (int i = h[x]; i; i = w[i].next) {
      int y = w[i].to;
      in[y]--;
      for (int xx = 1; xx <= n; xx++)
        if (Dis[x][xx] != 1 << 30) {
          if (Dis[x][xx] + w[i].c < Dis[y][xx + 1] && Dis[x][xx] + w[i].c > 0) {
            Dis[y][xx + 1] = Dis[x][xx] + w[i].c;
            p[y][xx + 1] = x;
            if (y == n && Dis[y][xx + 1] <= T) {
              if (xx + 1 > ans) {
                ans = xx + 1;
              }
            }
          }
        }
      if (in[y] == 0) {
        q[++tail] = y;
      }
    }
  }
}
void DG(int a, int b) {
  if (!a) return;
  DG(p[a][b], b - 1);
  printf("%d ", a);
}
void bfs() {
  qq[1] = 1;
  int l = 0, r = 1;
  while (l < r) {
    l++;
    int x = qq[l];
    for (int i = h[x]; i; i = w[i].next) {
      int y = w[i].to;
      in[y]++;
      if (!vis[y]) {
        qq[++r] = y;
        vis[y] = 1;
      }
    }
  }
}
int main() {
  int x, y, z;
  scanf("%d%d%d", &n, &m, &T);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    AddEdge(x, y, z);
  }
  bfs();
  Topo();
  printf("%d\n", ans);
  DG(n, ans);
  return 0;
}
