#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int INF = 0x3f3f3f3f;
int dp[N][N];
vector<pair<int, int> > ra[N];
int Head[N][N];
int calc(int dst, int cnt) {
  if (cnt < 0) return INF;
  if (dp[dst][cnt] != -1) return dp[dst][cnt];
  int &res = dp[dst][cnt];
  res = INF;
  for (int i = 0; i < ra[dst].size(); i++) {
    int u = ra[dst][i].first, t = ra[dst][i].second;
    int ures = calc(u, cnt - 1) + t;
    if (res > ures) {
      Head[dst][cnt] = u;
      res = ures;
    }
  }
  return res;
}
int main() {
  memset(dp, -1, sizeof(dp));
  dp[1][1] = 0;
  int n, m, tLimit;
  cin >> n >> m >> tLimit;
  for (int i = 0; i < m; i++) {
    int u, v, t;
    cin >> u >> v >> t;
    ra[v].push_back({u, t});
  }
  int cnt = 0;
  for (int i = n; i >= 1; i--) {
    if (calc(n, i) <= tLimit) {
      cnt = i;
      break;
    }
  }
  stack<int> ans;
  int cur = n, curCnt = cnt;
  while (cur != 1) {
    ans.push(cur);
    cur = Head[cur][curCnt--];
  }
  printf("%d\n", cnt);
  printf("1");
  while (ans.size()) {
    printf(" %d", ans.top());
    ans.pop();
  }
  printf("\n");
  return 0;
}
