#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
unordered_map<int, long long> dp[5135];
vector<pair<int, int> > mp[5135];
int T;
bool vis[5135];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  if (x == n) {
    dp[n][1] = 0;
    return;
  }
  for (auto c : mp[x]) {
    dfs(c.first);
    for (auto p : dp[c.first]) {
      if (dp[x].find(p.first + 1) == dp[x].end() ||
          dp[x][p.first + 1] > p.second + c.second)
        dp[x][p.first + 1] = p.second + c.second;
    }
  }
}
void pp(int x, int ans, long long v) {
  printf("%d ", x);
  if (x == n) exit(0);
  for (auto c : mp[x]) {
    long long tv = v - c.second;
    if (dp[c.first].find(ans - 1) != dp[c.first].end() &&
        dp[c.first][ans - 1] == tv) {
      pp(c.first, ans - 1, tv);
    }
  }
}
void fmain() {
  scanf("%d%d%d", &n, &m, &T);
  for (int i = 0, u, v, w; i < m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    mp[u].push_back({v, w});
  }
  dfs(1);
  int ans = 0;
  long long v = 0;
  for (auto p : dp[1]) {
    if (p.second <= T) {
      if (ans < p.first) v = p.second;
      ans = max(ans, p.first);
    }
  }
  printf("%d\n", ans);
  pp(1, ans, v);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) fmain();
  return 0;
}
