#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;
int N, M, R, T;
struct edge
{
int to;
long long cost;
edge(int to_, long long cost_) :
to(to_), cost(cost_) {}
};
const long long INF = 123456789012345;
using P = pair<long long, int>;//first:cost,second:vertice
void dijkstra(vector<edge>graph_[], long long dist[], int n_, int s_)
{
priority_queue<P, vector<P>, greater<P>>que;
que.push({ 0,s_ });
fill(dist, dist + n_, INF);
dist[s_] = 0ll;
while (!que.empty())
{
auto q = que.top();
que.pop();
long long thd = q.first;
int thv = q.second;
if (thd > dist[thv])
{
continue;
}
for (auto ed : graph_[thv])
{
if (dist[ed.to] > ed.cost + thd)
{
dist[ed.to] = ed.cost + thd;
que.push({ dist[ed.to],ed.to });
}
}
}
}
vector<edge>graph[2500];
LL dist[2500];
int main(void)
{
cin >> N >> M >> R >> T;
for (int i = 0; i < M; ++i)
{
int a, b, c;
cin >> a >> b >> c;
--a; --b;
graph[a].push_back(edge(b, c));
graph[b].push_back(edge(a, c));
}
LL ans = 0;
for (int A = 0; A < N; ++A)
{
dijkstra(graph, dist, N, A);
vector<LL>srt;
for (int i = 0; i < N; ++i)
{
if (dist[i])srt.push_back(dist[i]);
}
sort(srt.begin(), srt.end());
for (LL r : srt)
{
LL p = r * T / R;
if ((r*T) % R)p++;
LL can = lower_bound(srt.begin(),srt.end(),p) - srt.begin();
ans += can;
}
}
cout << ans << endl;
return 0;
}