#include <bits/stdc++.h>
using namespace std;
int n, m, lim;
struct node {
  int to;
  int val;
};
stack<int> ans;
vector<node> g[5500];
int f[5500][5500];
int fa[5500][5500];
void dfs(int u, int dep) {
  for (int i = 0; i != g[u].size(); i++) {
    int& co = g[u][i].val;
    int& v = g[u][i].to;
    if (f[dep][u] + co <= lim && f[dep][u] + co < f[dep + 1][v]) {
      fa[v][dep] = u;
      f[dep + 1][v] = f[dep][u] + co;
      dfs(v, dep + 1);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &lim);
  int t1, t2, t3;
  for (int i = 0; i != m; i++) {
    scanf("%d%d%d", &t1, &t2, &t3);
    g[t1].push_back(node{t2, t3});
  }
  memset(f, 0x7f, sizeof(f));
  f[1][1] = 0;
  dfs(1, 1);
  int i = n;
  while (!fa[n][i]) i--;
  cout << i + 1 << endl;
  ans.push(n);
  while (fa[n][i]) {
    ans.push(fa[n][i]);
    n = fa[n][i];
    i--;
  }
  cout << ans.top();
  ans.pop();
  while (!ans.empty()) {
    cout << " " << ans.top();
    ans.pop();
  }
  cout << endl;
}
