#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 5005, inf = 0x3f3f3f3f;
int id;
int n, m, k, mm, dis[maxn][maxn];
bool inque[maxn][maxn];
int pre[maxn][maxn];
struct edge {
  int v, w;
};
vector<edge> e[maxn];
void pri(int now, int res) {
  if (pre[now][res] == 0) {
    if (now == 1) {
      printf("1 ");
    }
    return;
  }
  pri(pre[now][res], res - 1);
  printf("%d ", now);
}
void spfa() {
  memset(dis, inf, sizeof dis);
  dis[1][0] = 0;
  queue<pair<int, int>> q;
  q.push({1, 0});
  while (!q.empty()) {
    auto x = q.front();
    q.pop();
    int u = x.first;
    int res = x.second;
    inque[u][res] = 0;
    for (auto y : e[u]) {
      int v = y.v;
      int w = y.w;
      if (dis[v][res + 1] > dis[u][res] + w && dis[u][res] + w <= k) {
        dis[v][res + 1] = dis[u][res] + w;
        pre[v][res + 1] = u;
        if (!inque[v][res + 1]) {
          q.push({v, res + 1});
          inque[v][res + 1] = 1;
        }
      }
    }
  }
}
signed main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    e[u].push_back((edge){v, w});
  }
  spfa();
  for (int i = n; i >= 0; i--) {
    if (dis[n][i] <= k) {
      mm = i;
      break;
    }
  }
  cout << mm + 1 << endl;
  pri(n, mm);
  return 0;
}
