#include using namespace std; using ll = long long; template using p_que = priority_queue,greater>; ll inf = (1LL<<60); int main(){ int n,m,p; ll mny; cin >> n >> m >> p >> mny; vector>>path (n,vector>(0)); for(int i=0;i> x >> y >> c; x--,y--; path[x].push_back({y,c}); path[y].push_back({x,c}); } vectormp (n,inf); mp[0] = 0; p_que>que; que.push({0,0}); while(!que.empty()){ auto[cst,pos] = que.top(); que.pop(); if(cst != mp[pos]) continue; for(auto[x,c]:path[pos]){ if(mp[x] > c + mp[pos]){ mp[x] = c + mp[pos]; que.push({x,mp[x]}); } } } ll ans = 0; for(int i=0;i> x >> c; x--; ll rm = max(0LL,mny - mp[x]); ans = max(ans,rm / c); } cout << ans << endl; }