#include <bits/stdc++.h>
using namespace std;
const int M = 5010;
const int Q = 1e9 + 7;
bool used[M];
vector<int> ord;
vector<pair<int, int> > g[M];
int dp[M][M];
int pos[M];
int p[M][M];
void dfs(int v) {
  used[v] = true;
  for (auto to : g[v]) {
    if (!used[to.first]) dfs(to.first);
  }
  ord.push_back(v);
}
int main() {
  srand(time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m, T;
  cin >> n >> m >> T;
  for (int i = 0; i < m; i++) {
    int u, v, t;
    cin >> u >> v >> t;
    g[u].push_back({v, t});
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) dfs(i);
  }
  for (int i = 0; i < (int)ord.size(); i++) pos[ord[i]] = i;
  int s = 0;
  while (ord[s] != n) s++;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) {
      dp[i][j] = Q;
      p[i][j] = -1;
    }
  dp[s][1] = 0;
  for (int i = s + 1; i < n; i++) {
    int v = ord[i];
    for (int j = 1; j <= n; j++) {
      for (auto to : g[v]) {
        if (dp[pos[to.first]][j - 1] + to.second < dp[i][j]) {
          dp[i][j] = dp[pos[to.first]][j - 1] + to.second;
          p[i][j] = pos[to.first];
        }
      }
    }
    if (v == 1) {
      for (int j = n; j >= 1; j--) {
        if (dp[i][j] <= T) {
          cout << j << endl;
          int cur = i;
          while (cur != -1) {
            cout << ord[cur] << " ";
            cur = p[cur][j--];
          }
          return 0;
        }
      }
    }
  }
  assert(0);
  return 0;
}
