#include <bits/stdc++.h>
using namespace std;
int n, m, sum, cnt, flag, t;
int deg[5050];
vector<int> g[5050], f[5050];
int dp[5050][5050], pre[5050][5050];
struct cmp {
  bool operator()(int a, int b) { return a > b; }
};
void topoSort() {
  priority_queue<int, vector<int>, cmp> q;
  for (int i = 1; i <= n; i++)
    if (deg[i] == 0) q.push(i), deg[i]--;
  while (!q.empty()) {
    int u = q.top();
    q.pop();
    sum--;
    for (int i = 0; i < g[u].size(); i++) {
      int e = g[u][i];
      deg[e]--;
      for (int j = 2; j <= n; j++) {
        if (dp[e][j] > dp[u][j - 1] + f[u][i])
          dp[e][j] = dp[u][j - 1] + f[u][i], pre[e][j] = u;
      }
    }
    for (int i = 1; i <= n; i++)
      if (deg[i] == 0) q.push(i), deg[i]--;
  }
}
void ini() {
  for (int i = 0; i <= n; i++) deg[i] = 0, flag = 0, g[i].clear(), f[i].clear();
  cnt = 0, sum = n;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) dp[i][j] = t + 100, pre[i][j] = -1;
  dp[1][1] = 0;
}
void add(int u, int v, int fe) {
  deg[v]++;
  g[u].push_back(v);
  f[u].push_back(fe);
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  ini();
  for (int i = 0; i < m; i++) {
    int u, v, fe;
    scanf("%d%d%d", &u, &v, &fe);
    add(u, v, fe);
  }
  topoSort();
  int Maxp = -1;
  for (int i = 1; i <= n; i++) {
    if (dp[n][i] <= t) Maxp = i;
  }
  stack<int> ss;
  int pos = n, lef = Maxp;
  cout << Maxp << endl;
  while (pos != -1) {
    ss.push(pos);
    pos = pre[pos][lef], lef--;
  }
  while (ss.size() > 1) cout << ss.top() << ' ', ss.pop();
  cout << ss.top() << endl;
  ss.pop();
  return 0;
}
