#include <bits/stdc++.h>
using namespace std;
const int N = 5015;
vector<pair<int, int> > adj[N];
bool is[N];
int n, T, p = 0;
int dp[N][N], par[N][N];
int main() {
  int m, i, j, x, y, t, l;
  cin >> n >> m >> T;
  for (i = 0; i < m; ++i)
    scanf("%d%d%d", &x, &y, &t), adj[x].push_back(make_pair(y, t));
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) dp[i][j] = 1e9 + 15;
  dp[1][1] = 0;
  for (l = 1; l < n; ++l) {
    for (i = 1; i <= n; ++i) {
      if (dp[i][l] >= T) continue;
      for (j = 0; j < adj[i].size(); ++j) {
        x = adj[i][j].first, t = adj[i][j].second;
        if (dp[x][l + 1] > dp[i][l] + t) {
          dp[x][l + 1] = dp[i][l] + t;
          par[x][l + 1] = i;
        }
      }
    }
  }
  for (i = n; i >= 1; --i)
    if (dp[n][i] <= T) {
      l = i;
      break;
    }
  printf("%d\n", l);
  vector<int> ret;
  while (l) {
    ret.push_back(n);
    n = par[n][l];
    --l;
  }
  for (i = ret.size() - 1; i >= 0; --i) printf("%d ", ret[i]);
  cout << endl;
}
