#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n, m, t;
const int maxn = 5e3 + 5;
vector<pair<int, int> > v[maxn];
int dp[maxn][maxn];
vector<int> temp;
bool visited[maxn];
void dfs(int id) {
  visited[id] = 1;
  for (auto it : v[id]) {
    if (visited[it.first]) continue;
    dfs(it.first);
  }
  temp.emplace_back(id);
}
void f(int id) {
  if (id == n) {
    dp[n][1] = 0;
    return;
  }
  for (auto i : v[id]) {
    for (int j = 1; j <= n; ++j) {
      if (dp[i.first][j] == -1) continue;
      if (dp[i.first][j] > t) continue;
      if (dp[id][j + 1] == -1)
        dp[id][j + 1] = i.second + dp[i.first][j];
      else
        dp[id][j + 1] = min(dp[id][j + 1], i.second + dp[i.first][j]);
    }
  }
}
vector<int> ans;
void find(int id, int k, int timeleft) {
  ans.emplace_back(id);
  if (k == 1) {
    return;
  }
  for (auto i : v[id]) {
    if (dp[i.first][k - 1] == -1) continue;
    if (dp[i.first][k - 1] == timeleft - i.second) {
      find(i.first, k - 1, timeleft - i.second);
      return;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> t;
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    v[x].emplace_back(y, z);
  }
  dfs(1);
  for (int i = 0; i < maxn; ++i) {
    for (int j = 0; j < maxn; ++j) {
      dp[i][j] = -1;
    }
  }
  for (auto it : temp) {
    f(it);
  }
  int r = 0;
  for (int i = 0; i < maxn; ++i) {
    if (dp[1][i] == -1 or dp[1][i] > t) continue;
    r = i;
  }
  find(1, r, dp[1][r]);
  cout << r << endl;
  for (auto i : ans) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}
