#include <bits/stdc++.h>
using namespace std;
void rf() {}
const int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1};
const int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2};
const int Nx[4] = {0, 0, -1, 1};
const int Ny[4] = {1, -1, 0, 0};
const long long LINF = (long long)5e18;
const int INF = 1e9 + 7;
const int N = 5000 + 228;
const int MAXN = 1e6 + 50;
const double EPS = 1e-9, PI = 3.14159265359;
inline int get_int() {
  char x = getchar();
  int ret = 0;
  bool neg = 0;
  while (!('0' <= x && x <= '9')) {
    if (x == '-') neg = 1;
    x = getchar();
  }
  while ('0' <= x && x <= '9') {
    ret = ret * 10 + x - '0';
    x = getchar();
  }
  if (neg) ret *= -1;
  return ret;
}
int n, m, t;
vector<pair<int, int> > v[N];
bool used[N];
vector<int> q;
int dp[N][N];
void dfs(int x) {
  used[x] = 1;
  for (auto it : v[x]) {
    if (!used[it.first]) dfs(it.first);
    for (int i = 2; i <= n; i++) {
      dp[x][i] = min(dp[x][i], dp[it.first][i - 1] + it.second);
    }
  }
}
int main() {
  srand(time(0));
  rf();
  cin >> n >> m >> t;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= (int)n; j++) dp[i][j] = INF;
  }
  while (m--) {
    int x, y, c;
    cin >> x >> y >> c;
    v[x].push_back(make_pair(y, c));
  }
  dp[n][1] = 0;
  dfs(1);
  int ans = -1;
  for (int i = 1; i <= n; i++) {
    if (dp[1][i] <= t) {
      ans = i;
    }
  }
  int cur = 1;
  if (ans == -1) {
    cout << 0;
    return 0;
  }
  vector<int> vv;
  vv.push_back(1);
  for (int i = ans; i >= 1; i--) {
    int z = 0;
    if (i == 1) continue;
    for (auto it : v[cur]) {
      if (dp[cur][i] == dp[it.first][i - 1] + it.second) {
        cur = it.first;
        vv.push_back(cur);
        break;
      }
    }
  }
  cout << int(vv.size()) << "\n";
  for (auto it : vv) cout << it << ' ';
  return 0;
}
