#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000, inf = 1 << 30;
int f[maxn + 1][maxn + 1];
int r[maxn + 1];
bool p[maxn + 1];
vector<int> last[maxn + 1];
int n, m, T;
queue<int> q;
struct quality {
  int to, data;
};
vector<quality> g[maxn + 50];
void print(int k, int i) {
  if (k == 1) {
    printf("%d ", k);
    return;
  }
  print(last[k][i], i - 1);
  printf("%d ", k);
}
int main() {
  scanf("%d %d %d", &n, &m, &T);
  for (int i = 0; i <= n; ++i) g[i].clear();
  memset(r, 0, sizeof(r));
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    ++r[b];
    g[a].push_back({b, c});
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j) f[i][j] = inf;
  while (!q.empty()) q.pop();
  memset(p, 0, sizeof(p));
  p[1] = 1;
  q.push(1);
  f[1][1] = 0;
  for (int i = 1; i <= n; ++i) last[i].clear();
  for (int i = 2; i <= n; ++i)
    if (r[i] == 0) q.push(i);
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (int i = 0; i < g[t].size(); ++i) {
      int k;
      for (int j = n; j >= 1; --j)
        if (f[g[t][i].to][j] > f[t][j - 1] + g[t][i].data) {
          k = j;
          break;
        }
      last[g[t][i].to].push_back(0), last[g[t][i].to].push_back(0);
      for (int j = 2; j <= k; ++j) {
        last[g[t][i].to].push_back(0);
        if (f[g[t][i].to][j] > f[t][j - 1] + g[t][i].data) {
          f[g[t][i].to][j] = f[t][j - 1] + g[t][i].data;
          last[g[t][i].to][j] = t;
        }
      }
      if (!(--r[g[t][i].to])) q.push(g[t][i].to);
    }
  }
  for (int i = n; i >= 1; --i)
    if (f[n][i] <= T) {
      printf("%d\n", i);
      print(n, i);
      break;
    }
  return 0;
}
