#include <bits/stdc++.h>
using namespace std;
struct S {
  int next;
  int cost;
};
vector<S> v[5050];
int dp[5005][5005];
struct SS {
  short int x, y;
  SS() { x = y = -1; }
} z[5005][5005];
void dfs(int pos, int n, int x) {
  if (pos == n) return;
  for (int i = 0; i < v[pos].size(); i++) {
    if (dp[v[pos][i].next][x + 1] >
        (long long)dp[pos][x] + (long long)v[pos][i].cost) {
      dp[v[pos][i].next][x + 1] = dp[pos][x] + v[pos][i].cost;
      z[v[pos][i].next][x + 1].x = pos;
      z[v[pos][i].next][x + 1].y = x;
      dfs(v[pos][i].next, n, x + 1);
    }
  }
}
int cy[5050];
int main() {
  int n, m, x, y, i, j;
  int T, t;
  cin >> n >> m >> T;
  for (i = 0; i < m; i++) {
    cin >> x >> y >> t;
    S cc;
    cc.next = y;
    cc.cost = t;
    v[x].push_back(cc);
  }
  for (i = 0; i <= n; i++)
    for (j = 0; j <= n; j++) dp[i][j] = 1e9 + 10;
  dp[1][1] = 0;
  dfs(1, n, 1);
  int ans = 0;
  for (i = 1; i <= n; i++)
    if (dp[n][i] <= T) ans = i;
  cout << ans << endl;
  int sum = 0;
  cy[sum++] = n;
  int a = z[n][ans].x;
  int b = z[n][ans].y;
  int aa = a, bb = b;
  while (1) {
    cy[sum++] = (a);
    if (a == 1) break;
    a = z[aa][bb].x;
    b = z[aa][bb].y;
    aa = a;
    bb = b;
  }
  for (i = ans - 1; i >= 0; i--) cout << cy[i] << " ";
}
