#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int inf = 1e9 + 1;
vector<pair<int, int> > adj[N];
int n, m, t, ans[N];
pair<int, int> trace[N][N];
queue<pair<pair<int, int>, int> > bell_lis;
int main() {
  cin >> n >> m >> t;
  int i, j, k, l, x, y;
  for (i = 1; i <= m; i++) {
    cin >> j >> k >> l;
    adj[j].push_back({k, l});
  }
  bell_lis.push({{1, 0}, 1});
  trace[1][1] = {0, 0};
  ans[1] = 1;
  while (bell_lis.size() != 0) {
    j = bell_lis.front().first.first;
    k = bell_lis.front().first.second;
    for (i = 0; i < adj[j].size(); i++) {
      if (k <= t - adj[j][i].second) {
        if (ans[adj[j][i].first] < bell_lis.front().second + 1) {
          ans[adj[j][i].first] = bell_lis.front().second + 1;
        }
        if (k + adj[j][i].second <
            trace[adj[j][i].first][bell_lis.front().second + 1].first) {
          trace[adj[j][i].first][bell_lis.front().second + 1].first =
              k + adj[j][i].second;
          trace[adj[j][i].first][bell_lis.front().second + 1].second = j;
          bell_lis.push({{adj[j][i].first, k + adj[j][i].second},
                         bell_lis.front().second + 1});
        }
        if (trace[adj[j][i].first][bell_lis.front().second + 1].first == 0) {
          trace[adj[j][i].first][bell_lis.front().second + 1].first =
              k + adj[j][i].second;
          trace[adj[j][i].first][bell_lis.front().second + 1].second = j;
          bell_lis.push({{adj[j][i].first, k + adj[j][i].second},
                         bell_lis.front().second + 1});
        }
      }
    }
    bell_lis.pop();
  }
  cout << ans[n] << endl;
  x = n;
  y = ans[n];
  t = ans[n];
  while (y > 0) {
    ans[y] = x;
    x = trace[x][y].second;
    y--;
  }
  for (i = 1; i <= t; i++) {
    cout << ans[i] << " ";
  }
}
