#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<pair<int, int> > v[5010];
pair<int, int> d[5010][5010];
vector<int> vv;
bool visit[5010] = {0};
void dfs(int x) {
  visit[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int xi = v[x][i].first;
    if (!visit[xi]) dfs(xi);
  }
  vv.push_back(x);
}
void out(int x, int y) {
  if (d[x][y].second != -1) out(d[x][y].second, y - 1);
  cout << x + 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));
  }
  for (int i = 0; i < n; i++)
    if (!visit[i]) dfs(i);
  reverse(vv.begin(), vv.end());
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = make_pair(1e9 + 7, -1);
    }
  }
  d[0][0] = make_pair(0, -1);
  for (int i = 0; i < n; i++) {
    int x = vv[i];
    for (int j = 0; j < v[x].size(); j++) {
      int xi = v[x][j].first;
      int yi = v[x][j].second;
      for (int k = 0; k < n; k++)
        d[xi][k + 1] = min(d[xi][k + 1], make_pair(d[x][k].first + yi, x));
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (d[n - 1][i].first <= k) {
      cout << i + 1 << "\n";
      out(n - 1, i);
      return 0;
    }
  }
  return 0;
}
