#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> second;
int x, n, m, T, ans;
void solve() {
  for (int i = 0; i < 5005; i++) {
    for (int j = 0; j < 5005; j++) dis[i][j] = 1e9 + 7;
  }
  dis[1][0] = 0;
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      q;
  q.push(make_pair(0, make_pair(1, 0)));
  while (!q.empty()) {
    pair<int, pair<int, int> > R = q.top();
    q.pop();
    int L = R.first;
    pair<int, int> u = R.second;
    if (L > dis[u.first][u.second] || L > T) continue;
    for (int j = 0; j < v[u.first].size(); j++) {
      pair<int, int> node = v[u.first][j];
      if (dis[node.first][u.second + 1] >
          dis[u.first][u.second] + node.second) {
        fa[node.first][u.second + 1] = u.first;
        dis[node.first][u.second + 1] = dis[u.first][u.second] + node.second;
        q.push(make_pair(dis[node.first][u.second + 1],
                         make_pair(node.first, u.second + 1)));
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    if (dis[n][i] <= T) ans = i;
  }
  cout << ans + 1 << endl;
  int x = n;
  while (x > 0) {
    second.push_back(x);
    x = fa[x][ans];
    ans--;
  }
  reverse(second.begin(), second.end());
  for (int i = 0; i < second.size(); i++) cout << second[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;
}
