#include <bits/stdc++.h>
const int MAXINT = 2147483640;
const int MAXLL = 9223372036854775800LL;
const int MAXN = 1000000;
const double eps = 1e-9;
const int mod = 1e9 + 7;
using namespace std;
int binpow(int a, int n) {
  int ans = 1;
  while (n) {
    if (n & 1) ans *= a;
    a *= a;
    n >>= 1;
  }
  return ans;
}
int n, m, t, a, b, c;
set<pair<int, pair<int, int> > > s;
vector<pair<int, int> > v[5001];
int f[5001][5001];
int dp[5001][5001];
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m >> t;
  for (int i = 1; i <= m; ++i) {
    cin >> a >> b >> c;
    v[a].push_back(make_pair(b, c));
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      dp[i][j] = 1e18;
    }
  }
  queue<pair<int, pair<int, int> > > q;
  q.push(make_pair(1, make_pair(0, 1)));
  while (!q.empty()) {
    int i = q.front().second.second, j = q.front().first,
        k = q.front().second.first;
    for (int j1 = 0; j1 < v[i].size(); ++j1) {
      int val = k + v[i][j1].second;
      int now = v[i][j1].first;
      if (dp[now][j + 1] > val && val <= t) {
        dp[now][j + 1] = val;
        f[now][j + 1] = i;
        q.push(make_pair(j + 1, make_pair(val, now)));
      }
    }
    q.pop();
  }
  for (int j = n; j >= 0; --j) {
    if (dp[n][j] <= t) {
      int now = n, kek = j;
      vector<int> vans;
      while (f[now][kek] != -1 && kek > 0) {
        vans.push_back(now);
        now = f[now][kek];
        kek--;
      }
      cout << vans.size() << endl;
      for (int i = vans.size() - 1; i >= 0; --i) {
        cout << vans[i] << " ";
      }
      return 0;
    }
  }
  return 0;
}
