#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;
const int N = 5e3 + 5, inf = 2e9;
vector<pair<ll, ll>> adj[N];
vector<ll> series(N);
vector<vector<ll>> dp(N, vector<ll>(N, 1e13));
ll t, T;
int nodesNum, edges, x, y, ans = 0;
bool dfs(int node, int num, ll tym) {
  if (dp[node][num] <= tym) return false;
  dp[node][num] = tym;
  if (node == nodesNum) {
    if (tym <= T && num > ans) {
      ans = num;
      series[num] = node;
      return true;
    }
    return false;
  }
  bool can = false;
  for (auto child : adj[node]) {
    if (dfs(child.first, num + 1, tym + child.second)) {
      series[num] = node;
      can = true;
    }
  }
  return can;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> nodesNum >> edges >> T;
  for (int i = 0; i < edges; i++) {
    cin >> x >> y >> t;
    adj[x].push_back({y, t});
  }
  series[1] = 1;
  for (auto child : adj[1]) {
    dfs(child.first, 2, child.second);
  }
  cout << ans << "\n";
  for (int i = 1; i <= ans; i++) {
    cout << series[i] << " ";
  }
  return 0;
}
