#include <bits/stdc++.h>
using namespace std;
int cost[5000][5000];
int minCost[5000][5000];
vector<short> g[5000];
vector<short> gt[5000];
bool visited[5000];
stack<short> sortedVertices;
void sortGraph(short parentV) {
  visited[parentV] = true;
  for (auto childV : g[parentV])
    if (!visited[childV]) sortGraph(childV);
  sortedVertices.push(parentV);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, T;
  cin >> n >> m >> T;
  for (int edge = 0; edge < m; edge++) {
    int u, v, c;
    cin >> u >> v >> c;
    u--;
    v--;
    g[u].push_back(v);
    gt[v].push_back(u);
    cost[u][v] = c;
  }
  for (int v = 0; v < n; v++)
    for (int pathLength = 0; pathLength < n; pathLength++)
      minCost[v][pathLength] = T + 1;
  minCost[0][0] = 0;
  sortGraph(0);
  while (!sortedVertices.empty()) {
    auto curV = sortedVertices.top();
    sortedVertices.pop();
    for (auto childV : g[curV])
      for (int pathLength = 0; pathLength < n - 1; pathLength++)
        minCost[childV][pathLength + 1] =
            min(minCost[childV][pathLength + 1],
                minCost[curV][pathLength] + cost[curV][childV]);
  }
  for (int pathLength = n - 1; pathLength > 0; pathLength--) {
    int targetVertex = n - 1;
    if (minCost[targetVertex][pathLength] <= T) {
      stack<short> longestPath;
      int curVertex = targetVertex;
      while (curVertex != 0) {
        pathLength--;
        longestPath.push(curVertex);
        int previousParent = gt[curVertex][0];
        for (auto parentV : gt[curVertex])
          if (minCost[parentV][pathLength] + cost[parentV][curVertex] ==
              minCost[curVertex][pathLength + 1]) {
            previousParent = parentV;
            break;
          }
        curVertex = previousParent;
      }
      longestPath.push(0);
      cout << longestPath.size() << endl;
      while (!longestPath.empty()) {
        cout << longestPath.top() + 1 << ' ';
        longestPath.pop();
      }
      break;
    }
  }
}
