#include <bits/stdc++.h>
using namespace std;
int n, m, T;
struct edge {
  int v, len;
};
short in[5010];
long long dp[5010][5010];
short path[5010][5010];
vector<edge> vec[5010];
int main() {
  scanf("%d%d%d", &n, &m, &T);
  for (register int i = 1; i <= m; i++) {
    int u, v, len;
    scanf("%d%d%d", &u, &v, &len);
    in[v]++;
    vec[u].push_back(edge{v, len});
  }
  queue<int> q;
  for (register int i = 1; i <= n; i++) {
    if (in[i] == 0) {
      q.push(i);
    }
    for (register int j = 1; j <= n; j++) {
      dp[i][j] = 1e18;
    }
  }
  dp[1][1] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (register int i = 0; i < vec[u].size(); i++) {
      int v = vec[u][i].v;
      in[v]--;
      for (register int j = 2; j <= n; j++) {
        if (dp[v][j] > dp[u][j - 1] + vec[u][i].len) {
          dp[v][j] = dp[u][j - 1] + vec[u][i].len;
          path[v][j] = u;
        }
      }
      if (in[v] == 0) {
        q.push(v);
      }
    }
  }
  for (register int i = n; i >= 1; i--) {
    if (dp[n][i] <= T) {
      printf("%d\n", i);
      int now = n;
      vector<int> ans;
      for (register int j = i; j >= 1; j--) {
        ans.push_back(now);
        now = path[now][j];
      }
      for (register int j = ans.size() - 1; j >= 0; j--) {
        printf("%d ", ans[j]);
      }
      break;
    }
  }
  return 0;
}
