#include <bits/stdc++.h>
using namespace std;
int n, m, T;
int d[5005][5005];
int pre[5005][5005];
bool visited[5005];
vector<vector<pair<int, int> > > v(5005);
void dp(int x) {
  if (visited[x]) return;
  visited[x] = 1;
  if (x == 1) {
    d[x][1] = 0;
    return;
  }
  for (auto it = v[x].begin(); it != v[x].end(); it++) {
    dp((*it).first);
    for (int i = 1; i < n + 1; i++) {
      if (d[(*it).first][i - 1] + (*it).second < d[x][i]) {
        d[x][i] = d[(*it).first][i - 1] + (*it).second;
        pre[x][i] = (*it).first;
      }
    }
  }
}
void solve(int n, int i) {
  if (i > 1) solve(pre[n][i], i - 1);
  cout << n << " ";
}
int main() {
  cin >> n >> m >> T;
  for (int i = 1; i < m + 1; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    v[y].push_back(make_pair(x, z));
  }
  memset(d, 0x3f, sizeof(d));
  dp(n);
  int i;
  for (i = n; i >= 0; i--) {
    if (d[n][i] <= T) break;
  }
  cout << i << endl;
  solve(n, i);
}
