#include <bits/stdc++.h>
using namespace std;
const int N = 5050;
const int inf = 0x3f3f3f3f;
int n, m, T;
int f[N][N];
short nxt[N][N];
vector<pair<int, int> > a[N];
bool vis[N];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (auto it : a[x]) {
    dfs(it.first);
    for (int i = 2; i <= n; ++i) {
      int dis = f[it.first][i - 1] + it.second;
      if (dis < f[x][i]) {
        f[x][i] = dis;
        nxt[x][i] = it.first;
      }
    }
  }
}
void print() {
  for (int i = n;; --i)
    if (f[1][i] <= T) {
      printf("%d\n", i);
      int x = 1;
      printf("%d ", x);
      while (x != n) {
        x = nxt[x][i--];
        printf("%d ", x);
      }
      puts("");
      break;
    }
}
int main() {
  while (~scanf("%d%d%d", &n, &m, &T)) {
    for (int i = 1; i <= n; ++i) a[i].clear(), vis[i] = 0;
    for (int i = 1; i <= m; ++i) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      if (y == 1 || x == n) continue;
      a[x].push_back({y, z});
    }
    memset(f, inf, sizeof(f));
    ;
    f[n][1] = 0;
    vis[n] = 1;
    dfs(1);
    print();
  }
  return 0;
}
