#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

struct Edge {
	int from, to, cost;
};
int main(){
	const auto comparator = [](std::pair<int, int> a, std::pair<int, int> b) { return a.second > b.second; };
	using Queue = std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(comparator)>;
	while (true) {
		int n, m, c; std::cin >> n >> m >> c; if (n == 0 && m == 0 && c == 0) break;
		std::vector<std::vector<Edge>> nodes(n);
		for (auto i = 0; i < m; ++i) {
			int f, t, cost; std::cin >> f >> t >> cost; --f, --t;
			nodes[f].push_back(Edge{ f, t, cost });
		}
		std::vector<std::vector<int>> min_cost(2, std::vector<int>(n, INT_MAX));
		Queue queue(comparator);
		min_cost[0][0] = 0;
		queue.emplace(0, 0);
		while (!queue.empty()) {
			const auto top = queue.top(); queue.pop();
			if (min_cost[0][top.first] != top.second) continue;
			for (const auto e : nodes[top.first]) {
				if (min_cost[0][e.to] > e.cost + top.second) {
					min_cost[0][e.to] = e.cost + top.second;
					queue.emplace(e.to, e.cost + top.second);
				}
			}
		}
		for (auto i = 1; i <= n; ++i) {
			const auto current = i & 1;
			const auto prev = current ^ 1;
			std::copy(min_cost[prev].begin(), min_cost[prev].end(), min_cost[current].begin());
			for (const auto node : nodes) {
				for (const auto e : node) {
					if (min_cost[current][e.to] > min_cost[prev][e.from]) {
						min_cost[current][e.to] = min_cost[prev][e.from];
						queue.emplace(e.to, min_cost[current][e.to]);
					}
				}
			}
			while (!queue.empty()) {
				const auto top = queue.top(); queue.pop();
				if (min_cost[current][top.first] != top.second) continue;
				for (const auto e : nodes[top.first]) {
					if (min_cost[current][e.to] > e.cost + top.second) {
						min_cost[current][e.to] = e.cost + top.second;
						queue.emplace(e.to, e.cost + top.second);
					}
				}
			}
			if (min_cost[current].back() <= c) {
				std::cout << i << '\n';
				break;
			}
		}
	}
}

