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