#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
const int inf = 1e9 + 7;
vector<pair<int, int> > adj[MAXN];
int dp[MAXN][MAXN], tr[MAXN][MAXN];
int n, m, t;
int solve(int u, int len) {
  if (u == n and !len) return 0;
  if (!len) return inf;
  if (dp[u][len] != -1) return dp[u][len];
  int ret = inf;
  for (int i = 0; i < ((int)adj[u].size()); i++) {
    int v = adj[u][i].first;
    int c = adj[u][i].second;
    long long x = solve(v, len - 1) + c;
    if (x < ret) ret = x, tr[u][len] = v;
  }
  return dp[u][len] = ret;
}
void process() {
  memset(dp, -1, sizeof(dp));
  for (int i = 5000; i >= 0; i--) {
    int ans = solve(1, i);
    if (ans <= t) {
      printf("%d\n%d ", i + 1, 1);
      int x = 1;
      while (i--) {
        x = tr[x][i + 1];
        printf("%d ", x);
      }
    }
  }
}
int main(void) {
  scanf("%d%d%d", &n, &m, &t);
  for (int u, v, c, i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &c);
    adj[u].push_back(make_pair(v, c));
  }
  process();
}
