#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int n, t, m;
vector<pair<int, int> > g[5007];
pair<int, int> dp[5007][5007];
void read() {
  scanf("%d %d %d", &n, &m, &t);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    g[b].push_back({a, c});
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) dp[i][j].first = INF;
  dp[1][1].first = 0;
}
void solve() {
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < (int)g[j].size(); k++)
        dp[i][j] =
            min(make_pair(dp[i - 1][g[j][k].first].first + g[j][k].second,
                          g[j][k].first),
                dp[i][j]);
    }
  }
}
void wypisz() {
  vector<int> v;
  int id;
  pair<int, int> x;
  for (int i = 1; i <= n; i++)
    if (dp[i][n].first <= t) x = dp[i][n], id = i;
  while (x.second != 1) {
    v.push_back(x.second);
    x = dp[--id][x.second];
  }
  v.push_back(1);
  reverse(v.begin(), v.end());
  v.push_back(n);
  printf("%d\n", (int)v.size());
  for (auto p : v) printf("%d ", p);
}
int main() {
  read();
  solve();
  wypisz();
  return 0;
}
