#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > G[5005];
int n, T[5005][5005], trace[5005][5005], time_limit, m, u, v, w;
bool vis[5005];
vector<int> ans, a;
void bfs() {
  for (int i = 1; i <= n; i++) {
    vis[i] = false;
    for (int j = 1; j <= n; j++) T[i][j] = -1;
  }
  T[1][1] = 0;
  for (int h = a.size() - 1; h >= 0; h--) {
    int u = a[h];
    vis[u] = true;
    for (int i = 0; i < (int)G[u].size(); i++) {
      int v = G[u][i].first;
      for (int j = 1; j <= n; j++) {
        if (T[u][j] == -1) continue;
        if (T[v][j + 1] == -1 || T[v][j + 1] > T[u][j] + G[u][i].second) {
          T[v][j + 1] = T[u][j] + G[u][i].second;
          trace[v][j + 1] = u;
        }
      }
    }
  }
  int min_time;
  for (int j = n; j >= 1; j--) {
    if (T[n][j] > -1 && T[n][j] <= time_limit) {
      min_time = j;
      break;
    }
  }
  int x = n;
  int y = min_time;
  ans.push_back(n);
  while (trace[x][y] > 0) {
    ans.push_back(trace[x][y]);
    x = trace[x][y];
    y--;
  }
}
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = true;
  for (int i = 0; i < (int)G[u].size(); i++) {
    dfs(G[u][i].first);
  }
  a.push_back(u);
}
int main() {
  scanf("%d%d%d", &n, &m, &time_limit);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    G[u].push_back(pair<int, int>(v, w));
  }
  dfs(1);
  bfs();
  printf("%d\n", (int)ans.size());
  for (int i = ans.size() - 1; i >= 0; i--) {
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
