#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, pair<int, int> > > pq;
bool vis[5030][5030];
int dis[5030][5030], fa[5030][5030];
vector<pair<int, int> > v[5030];
vector<int> sc;
int x, n, m, T, ans;
void solve() {
  int node = 1;
  memset(dis, -1, sizeof dis);
  pq.push({0, {node, 0}});
  dis[node][0] = 0;
  while (!pq.empty()) {
    long long cur = pq.top().second.first, d = pq.top().first * -1,
              pass = pq.top().second.second;
    pq.pop();
    if (d > dis[cur][pass] || d > T) continue;
    vis[cur][pass] = 1;
    for (auto pp : v[cur]) {
      if (dis[pp.first][pass + 1] == -1 ||
          dis[pp.first][pass + 1] > dis[cur][pass] + pp.second) {
        dis[pp.first][pass + 1] = dis[cur][pass] + pp.second;
        fa[pp.first][pass + 1] = cur;
        pq.push({dis[pp.first][pass + 1] * -1, {pp.first, pass + 1}});
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (dis[n][i] <= T && dis[n][i] != -1) ans = i;
  }
  cout << ans + 1 << endl;
  int x = n;
  while (x != 1) {
    sc.push_back(x);
    x = fa[x][ans];
    ans--;
  }
  sc.push_back(1);
  reverse(sc.begin(), sc.end());
  for (int i = 0; i < sc.size(); i++) cout << sc[i] << " ";
  cout << endl;
}
int main() {
  cin >> n >> m >> T;
  for (int i = 0; i < m; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    v[x].push_back({y, t});
  }
  solve();
  return 0;
}
