#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<pair<int, int> > v[5010];
int d[5010][5010];
int par[5010][5010];
int res = 1e9 + 7;
int dp(int x, int y) {
  if (d[x][y] != -1) return d[x][y];
  if (!y) {
    if (x == n - 1) {
      d[x][y] = 0;
      return 0;
    } else
      return 1e9 + 7;
  }
  int t = 1e9 + 7;
  for (int i = 0; i < v[x].size(); i++) {
    int xi = v[x][i].first;
    int yi = v[x][i].second;
    if (dp(xi, y - 1) + yi < t) {
      par[x][y] = xi;
      t = dp(xi, y - 1) + yi;
    }
  }
  d[x][y] = t;
  return t;
}
void out(int x, int y) {
  cout << x + 1 << " ";
  if (y) out(par[x][y], y - 1);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--, y--;
    v[x].push_back(make_pair(y, c));
  }
  memset(d, -1, sizeof(d));
  for (int i = n - 1; i > 0; i--) {
    if (dp(0, i) <= k) {
      cout << i + 1 << "\n";
      out(0, i);
      return 0;
    }
  }
  return 0;
}
