#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000100;
int timer, max_t, n, m;
int dp[5000][5000];
int p[5000][5000];
vector<int> ans;
vector<pair<int, int> > g[5000];
int main() {
  cin >> n >> m >> max_t;
  for (int i = 0; i < m; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    x--;
    y--;
    g[y].push_back(make_pair(x, t));
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  p[0][0] = -1;
  for (int i = 1; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int z = 0; z < g[j].size(); z++)
        if (dp[j][i] > dp[g[j][z].first][i - 1] + g[j][z].second &&
            dp[g[j][z].first][i - 1] <= max_t) {
          dp[j][i] = dp[g[j][z].first][i - 1] + g[j][z].second;
          p[j][i] = g[j][z].first;
        }
  for (int i = n - 1; i > 0; i--)
    if (dp[n - 1][i] <= max_t) {
      int v = n - 1, tt = i;
      while (v != -1) {
        ans.push_back(v);
        v = p[v][tt];
        tt--;
      }
      break;
    }
  cout << ans.size() << endl;
  for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i] + 1 << " ";
  return 0;
}
