#include <bits/stdc++.h>
using namespace std;
template <typename T>
T& max(T& a, T& b) {
  if (a >= b) return a;
  return b;
}
template <typename T>
T& min(T& a, T& b) {
  if (a < b) return a;
  return b;
}
template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T get() {
  T a;
  cin >> a;
  return a;
}
template <typename T>
T rev(T a) {
  reverse(a.begin(), a.end());
  return a;
}
template <typename T>
vector<T>& sort(vector<T>& a) {
  sort(a.begin(), a.end());
  return a;
}
const long long inf = 3e18;
const double eps = 1e-9;
struct edge {
  long long to, cost;
  edge(long long to, long long cost) : to(to), cost(cost) {}
};
struct Cost {
  long long cost;
  long long v;
  long long num;
  bool operator<(Cost c) const {
    if (num == c.num) return cost > c.cost;
    return num > c.num;
  }
  Cost(long long cost, long long v, long long num)
      : cost(cost), v(v), num(num) {}
};
long long N, M, T;
vector<edge> G[5010];
long long d[5010][5010];
short prevv[5000][5000];
void dijkstra(long long s) {
  for (long long i = 0; i < (long long)(N); ++i)
    for (long long j = 0; j < (long long)(N); ++j) d[i][j] = inf;
  priority_queue<Cost> q;
  d[0][s] = 0;
  q.push(Cost(0, s, 0));
  while (q.size()) {
    Cost p = q.top();
    q.pop();
    long long v = p.v;
    long long num = p.num;
    long long nxt_num = p.num + 1;
    if (d[num][v] < p.cost) continue;
    for (long long i = 0; i < (long long)(G[v].size()); ++i) {
      edge e = G[v][i];
      if (d[nxt_num][e.to] > d[num][v] + e.cost) {
        d[nxt_num][e.to] = d[num][v] + e.cost;
        q.push(Cost(d[nxt_num][e.to], e.to, nxt_num));
        prevv[nxt_num][e.to] = v;
      }
    }
  }
}
signed main() {
  cin >> N >> M >> T;
  for (long long i = 0; i < (long long)(M); ++i) {
    long long u, v, t;
    cin >> u >> v >> t;
    --u, --v;
    G[u].push_back(edge(v, t));
  }
  dijkstra(0);
  vector<long long> route;
  route.push_back(N - 1);
  long long now = N - 1;
  long long n;
  for (long long i = N - 1; i >= 0; --i) {
    if (d[i][now] <= T) {
      n = i;
      break;
    }
  }
  while (n) {
    route.push_back(prevv[n][now]);
    now = prevv[n][now];
    n -= 1;
  }
  reverse(route.begin(), route.end());
  cout << route.size() << endl;
  for (long long i = 0; i < (long long)(route.size()); ++i) {
    if (i) cout << ' ';
    cout << route[i] + 1;
  }
  cout << endl;
}
