#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if ((a == 0) || (b == 0)) return a + b;
  return gcd(b, a % b);
}
long long pow_mod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return (res % 1000000007);
}
long long pow_2(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return res;
}
bool isPrime(long long a) {
  for (int i = 3; (i * i) <= a; i += 2) {
    if ((a % i) == 0) return false;
  }
  if ((a != 2) && ((a % 2) == 0)) return false;
  if (a == 1) return false;
  return true;
}
string con_ll_to_str(int a) {
  stringstream mystr;
  mystr << a;
  return mystr.str();
}
long long con_str_to_ll(string st) {
  long long numb = 0;
  int len = st.size(), i, j = 0;
  for (i = len - 1; i >= 0; i--) {
    numb += (pow_2(10, j) * (st[i] - '0'));
    j++;
  }
  return numb;
}
long long baseno_to_decimal(string st, long long basee) {
  long long i = 0, j, anss = 0;
  for (j = (int)st.length() - 1; j >= 0; j--) {
    anss += (st[j] - '0') * pow_2(basee, i);
    i++;
  }
  return anss;
}
string decimal_to_string(long long num, long long basee) {
  long long i = 0, j, opop;
  string anss = "";
  vector<string> stri;
  stri.push_back("0");
  stri.push_back("1");
  stri.push_back("2");
  stri.push_back("3");
  stri.push_back("4");
  stri.push_back("5");
  stri.push_back("6");
  stri.push_back("7");
  stri.push_back("8");
  stri.push_back("9");
  stri.push_back("A");
  stri.push_back("B");
  stri.push_back("C");
  stri.push_back("D");
  stri.push_back("E");
  stri.push_back("F");
  while (num) {
    opop = num % basee;
    anss += stri[opop];
    num /= basee;
  }
  reverse(anss.begin(), anss.end());
  return anss;
}
bool vis[5005];
int dp[5005][5005], par[5005][5005];
vector<pair<int, int> > vc[5005];
stack<int> stac;
vector<int> ans;
void toposort(int vert) {
  vis[vert] = 1;
  int i, h = vc[vert].size();
  for (i = 0; i <= h - 1; i++) {
    if (!vis[vc[vert][i].first]) {
      toposort(vc[vert][i].first);
    }
  }
  stac.push(vert);
}
void dfs(int M) {
  bool flag = 0;
  int i, vert, h, j;
  while (!stac.empty()) {
    vert = stac.top();
    stac.pop();
    if (vert == 1) flag = 1;
    if (!flag) continue;
    h = vc[vert].size();
    for (i = 0; i <= h - 1; i++) {
      for (j = 1; j <= M; j++) {
        if ((dp[vc[vert][i].first][j] >
             (dp[vert][j - 1] + vc[vert][i].second)) &&
            (dp[vert][j - 1] <= 1e9)) {
          par[vc[vert][i].first][j] = vert;
          dp[vc[vert][i].first][j] = dp[vert][j - 1] + vc[vert][i].second;
        }
      }
    }
  }
}
void backtrack(int edge, int N) {
  int vert = N, i;
  ans.push_back(N);
  while (edge >= 0) {
    ans.push_back(par[vert][edge]);
    if (par[vert][edge] == 1) break;
    vert = par[vert][edge];
    edge--;
  }
  for (i = (int)ans.size() - 1; i >= 0; i--) {
    cout << ans[i] << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, M, T, i, j, U, V, t;
  cin >> N >> M >> T;
  for (i = 1; i <= M; i++) {
    cin >> U >> V >> t;
    vc[U].push_back(make_pair(V, t));
  }
  for (i = 1; i <= N; i++) {
    for (j = 0; j <= M; j++) {
      dp[i][j] = INT_MAX;
    }
  }
  dp[1][0] = 0;
  toposort(1);
  dfs(M);
  for (i = M; i >= 1; i--) {
    if (dp[N][i] <= T) {
      cout << i + 1 << "\n";
      backtrack(i, N);
      return 0;
    }
  }
  return 0;
}
