#include <bits/stdc++.h>
template <class T>
inline void rd(T &x) {
  char c = getchar();
  x = 0;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
}
using namespace std;
const int oo = 1e9 + 7;
const int maxn = 1e4 + 20;
vector<pair<int, int> > G[maxn];
int n, m, t;
int dp[5022][5022];
int pre[5022][5022];
bool vis[maxn];
int s[maxn];
int de[maxn];
deque<int> q;
void go() {
  memset(dp, 0x3f, sizeof(dp));
  pre[1][1] = -1;
  dp[1][1] = 0;
  for (int ii = 1; ii < n + 1; ii++) {
    int u = s[ii];
    for (int j = 1; j < n + 1; j++)
      if (dp[u][j] != 0x3f3f3f3f) {
        for (auto e : G[u]) {
          int v = e.first;
          int c = e.second + dp[u][j];
          if (c < dp[v][j + 1] && c <= t) {
            dp[v][j + 1] = c;
            pre[v][j + 1] = u;
          }
        }
      }
  }
}
void topo() {
  for (int i = 1; i < n + 1; i++) {
    int id = -1;
    for (int j = 1; j < n + 1; j++)
      if (!vis[j]) {
        if (id == -1 || de[j] < de[id]) id = j;
      }
    s[i] = id;
    vis[id] = 1;
    for (auto e : G[id]) {
      de[e.first]--;
    }
  }
}
int main() {
  int u, v, c;
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &c);
    G[u].push_back({v, c});
    de[v]++;
  }
  topo();
  go();
  int ans = 0;
  for (int i = 1; i < n + 1; i++)
    if (dp[n][i] != 0x3f3f3f3f) {
      ans = i;
    }
  printf("%d\n", ans);
  int now = n;
  vector<int> tmp;
  while (now != -1) {
    tmp.push_back(now);
    now = pre[now][ans--];
  }
  for (int i = tmp.size() - 1; i >= 0; i--) printf("%d ", tmp[i]);
  printf("\n");
  return 0;
}
