#include <bits/stdc++.h>
using namespace std;
const int MAX = 5000 + 5;
int parent[MAX][MAX];
int dist[MAX][MAX], n, m, t, x, y, w;
vector<pair<int, int> > adj[MAX];
void print(int u, int c) {
  if (u == 0) return;
  print(parent[u][c], c - 1);
  cout << u << " ";
}
void dijkstra(int from) {
  dist[from][0] = 0;
  priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >,
                 greater<pair<pair<int, int>, int> > >
      q;
  q.push({{0, 0}, from});
  while (!q.empty()) {
    const auto p = q.top();
    q.pop();
    int u = p.second, c = p.first.first, w = p.first.second;
    for (const auto &v : adj[u])
      if (dist[u][c] + v.second < dist[v.first][c + 1] &&
          dist[u][c] + v.second <= t) {
        dist[v.first][c + 1] = dist[u][c] + v.second;
        parent[v.first][c + 1] = u;
        q.push({{c + 1, dist[v.first][c + 1]}, v.first});
      }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> t;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> w;
    adj[x].push_back({y, w});
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= n; j++) dist[i][j] = 1e15;
  dijkstra(1);
  int x;
  for (int i = 0; i <= n; i++)
    if (dist[n][i] <= t) x = i;
  cout << x + 1 << "\n";
  print(n, x);
  return 0;
}
