#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 1;
int d[5010][5010], way_back[5010][5010];
vector<int> p[5010], t[5010], ans;
int n, m, T;
int main() {
  int to, from, t_i;
  cin >> n >> m >> T;
  for (int i = 0; i < m; i++) {
    cin >> from >> to >> t_i;
    p[to].push_back(from);
    t[to].push_back(t_i);
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) d[i][j] = inf;
  d[1][1] = 0;
  int i, j, k, prev;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      for (k = 0; k < p[j].size(); k++) {
        prev = p[j][k];
        if (d[i][j] > d[i - 1][prev] + t[j][k]) {
          d[i][j] = d[i - 1][prev] + t[j][k];
          way_back[i][j] = prev;
        }
      }
  for (i = n; i >= 2; i--)
    if (d[i][n] <= T) break;
  for (j = n; i > 0; i--) {
    ans.push_back(j);
    j = way_back[i][j];
  }
  cout << ans.size() << endl;
  for (i = ans.size() - 1; i >= 0; i--) cout << ans[i] << ' ';
  return 0;
}
