#include <bits/stdc++.h>
using namespace std;
int n, m, T;
vector<vector<pair<int, int> > > v;
bool visit[5010];
int d[5010][5010], pre[5010][5010];
vector<int> tp, res;
int r;
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]) continue;
    dfs(xi);
  }
  tp.push_back(x);
}
int main() {
  cin >> n >> m >> T;
  v.resize(n);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    v[x].push_back(make_pair(y, z));
  }
  for (int i = 0; i < n; i++) {
    if (visit[i]) continue;
    dfs(i);
  }
  reverse(tp.begin(), tp.end());
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= n; j++) d[i][j] = 1e9 + 7;
  }
  d[0][1] = 0;
  for (int i = 0; i < n; i++) {
    int x = tp[i];
    for (int j = 1; j < n; j++) {
      if (d[x][j] == 1e9 + 7) continue;
      for (int k = 0; k < v[x].size(); k++) {
        int xi = v[x][k].first;
        int yi = v[x][k].second;
        if (d[xi][j + 1] > d[x][j] + yi) {
          d[xi][j + 1] = d[x][j] + yi;
          pre[xi][j + 1] = x;
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (d[n - 1][i] <= T) {
      r = i;
      break;
    }
  }
  int x = n - 1;
  while (r > 1) {
    res.push_back(x + 1);
    x = pre[x][r];
    r--;
  }
  res.push_back(1);
  cout << res.size() << "\n";
  for (int i = res.size() - 1; i >= 0; i--) cout << res[i] << " ";
  return 0;
}
