#include using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; ll X; cin>>N>>M>>X; vector>>G(N); for(int i=0;i>u>>v>>A>>B; --u,--v; G[u].push_back({v,A,B}); G[v].push_back({u,A,B}); } ll ans=-1,ng=1e9+1; while(ng-ans>1){ int yokan=(ans+ng)/2; vectordist(N,X+1); dist[0]=0; priority_queue,vector>,greater>>pq; pq.push({0,0}); while(pq.size()){ ll d=pq.top()[0],v=pq.top()[1]; pq.pop(); if(dist[v]=yokan&&dist[i[0]]>d+i[1]){ dist[i[0]]=d+i[1]; pq.push({dist[i[0]],i[0]}); } } } if(dist[N-1]<=X){ ans=yokan; }else{ ng=yokan; } } cout<