#include <bits/stdc++.h>
using namespace std;
int dp[5005][5005];
int pre[5005][5005];
vector<pair<int, int> > V[5005];
int n, m, T;
struct Node {
  int x;
  int step;
  int t;
};
void bfs() {
  Node nd;
  nd.x = 1;
  nd.step = 1;
  nd.t = 0;
  dp[1][1] = 0;
  queue<Node> Q;
  Q.push(nd);
  while (!Q.empty()) {
    nd = Q.front();
    Q.pop();
    int x = nd.x;
    int step = nd.step + 1;
    int t = nd.t;
    for (int i = 0; i < V[x].size(); ++i) {
      int w = V[x][i].first;
      int ttt = t + V[x][i].second;
      if (ttt <= 1000000000)
        if (dp[w][step] > ttt || dp[w][step] == -1) {
          pre[w][step] = x;
          dp[w][step] = ttt;
          Node tmp;
          tmp.x = w;
          tmp.step = step;
          tmp.t = ttt;
          Q.push(tmp);
        }
    }
  }
  int mx = 0;
  int index = -1;
  for (int i = 0; i <= 5000; ++i) {
    if (dp[n][i] != -1 && dp[n][i] <= T) {
      mx = max(mx, i);
    }
  }
  cout << mx << endl;
  vector<int> ans;
  ans.push_back(n);
  int tx = dp[n][mx];
  int point = n;
  while (pre[point][mx] != -1) {
    ans.push_back(pre[point][mx]);
    point = pre[point][mx];
    mx--;
  }
  for (int i = ans.size() - 1; i >= 0; --i) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
int main() {
  memset(dp, -1, sizeof dp);
  memset(pre, -1, sizeof pre);
  cin >> n >> m >> T;
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    V[a].push_back(make_pair(b, c));
  }
  bfs();
  return 0;
}
