#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int inf = 1684300900;
int n, m, T;
vector<int> e[N], w[N];
int dp[N][N], pre[N][N];
bool p[N][N];
queue<int> q, qp;
void spfa() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= n; ++j) {
      dp[i][j] = inf;
    }
  }
  pre[0][1] = -1;
  dp[0][1] = 0;
  p[0][1] = 1;
  q.push(0);
  qp.push(1);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    int num = qp.front();
    qp.pop();
    p[cur][num] = 0;
    for (int i = 0; i < e[cur].size(); ++i) {
      int u = e[cur][i];
      if (dp[u][num + 1] > dp[cur][num] + w[cur][i]) {
        dp[u][num + 1] = dp[cur][num] + w[cur][i];
        if (dp[u][num + 1] > T) continue;
        pre[u][num + 1] = cur;
        if (p[u][num + 1] == 0) {
          p[u][num + 1] = 1;
          q.push(u);
          qp.push(num + 1);
        }
      }
    }
  }
}
void print(int cur, int num) {
  if (num == 0) return;
  print(pre[cur][num], num - 1);
  printf("%d ", cur + 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &T);
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    e[--x].push_back(--y);
    w[x].push_back(z);
  }
  spfa();
  for (int i = n; i >= 2; --i) {
    if (dp[n - 1][i] <= T) {
      printf("%d\n", i);
      print(n - 1, i);
      break;
    }
  }
  return 0;
}
