#include <bits/stdc++.h>
using namespace std;
int n, m;
int T;
int d[5002];
bool vis[5002];
vector<int> vec[5002], vt[5002];
short pre[5002][5002];
int show[5002][5002];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (auto y : vec[x]) dfs(y);
}
void find() {
  memset(pre, -1, sizeof(pre));
  for (int i = (1); i <= (n); i++)
    for (int j = (0); j <= (n); j++) show[i][j] = ((1LL << 31) - 1);
  show[1][1] = 0;
  queue<int> q;
  q.push(1);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = (0); i < (vec[x].size()); i++) {
      int y = vec[x][i];
      long long t = vt[x][i];
      d[y]--;
      if (!d[y]) q.push(y);
      for (int j = (1); j < (n); j++) {
        int tt = min(show[x][j] + t, ((1LL << 31) - 1));
        if (show[y][j + 1] > tt) {
          pre[y][j + 1] = x;
          show[y][j + 1] = tt;
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> T;
  for (int i = (0); i < (m); i++) {
    int x, y, z;
    cin >> x >> y >> z;
    vec[x].push_back(y);
    vt[x].push_back(z);
  }
  d[1] = 0;
  dfs(1);
  for (int i = (1); i <= (n); i++)
    if (vis[i])
      for (auto y : vec[i]) d[y]++;
  find();
  int ans = 1;
  for (int i = (1); i <= (n); i++)
    if (show[n][i] != ((1LL << 31) - 1) && show[n][i] <= T) ans = i;
  vector<int> v;
  for (int cur = n; cur != -1; cur = pre[cur][ans + 1]) {
    v.push_back(cur);
    ans--;
  }
  cout << v.size() << '\n';
  for (auto it = v.rbegin(); it != v.rend(); it++) cout << *it << ' ';
  cout << '\n';
  return 0;
}
