#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[5005];
int dp[5005][5005];
int path[5005][5005];
int in[5005];
int n, m, t;
queue<int> q;
void Init() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    g[a].push_back(make_pair(c, b));
    in[b]++;
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[1][1] = 0;
  for (int i = 1; i <= n; i++)
    if (!in[i]) q.push(i);
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (int i = 0; i < g[t].size(); i++) {
      int to = g[t][i].second;
      int cost = g[t][i].first;
      if (in[to]) {
        in[to]--;
        for (int j = 2; j <= n; j++)
          if (dp[to][j] > dp[t][j - 1] + cost) {
            dp[to][j] = dp[t][j - 1] + cost;
            path[to][j] = t;
          }
      }
      if (!in[to]) q.push(to);
    }
  }
}
void out(int x, int now) {
  if (x <= 1) {
    if (x) printf("%d", x);
    return;
  }
  out(path[x][now], now - 1);
  printf(" %d", x);
}
void Print() {
  int res = 0;
  for (int i = n; i >= 1; i--) {
    if (dp[n][i] <= t) {
      res = i;
      break;
    }
  }
  printf("%d\n", res);
  if (res) {
    out(n, res);
    putchar('\n');
  }
}
int main() {
  Init();
  Print();
  return 0;
}
