#include <bits/stdc++.h>
using namespace std;
int n, w, cap, a[200005][4], need, ans, shortest[200005];
vector<pair<long long, int> > v[200005];
priority_queue<pair<long long, int> > Q;
int main() {
  memset(shortest, -1, sizeof(shortest));
  scanf("%d %d %d", &n, &w, &cap);
  for (int i = 1; i <= w; i++) {
    scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
    v[a[i][0]].push_back(make_pair(a[i][2], a[i][1]));
    v[a[i][1]].push_back(make_pair(a[i][2], a[i][0]));
  }
  scanf("%d", &need);
  Q.push(make_pair(0, cap));
  while (!Q.empty()) {
    pair<long long, int> x = Q.top();
    Q.pop();
    if (shortest[x.second] != -1) continue;
    shortest[x.second] = -x.first;
    if (-x.first == need) ans++;
    for (int i = 0; i <= (int)v[x.second].size() - 1; i++)
      Q.push(make_pair(x.first - v[x.second][i].first, v[x.second][i].second));
  }
  for (int i = 1; i <= w; i++) {
    long long costmin = shortest[a[i][0]] < shortest[a[i][1]]
                            ? shortest[a[i][0]]
                            : shortest[a[i][1]];
    long long costmax = shortest[a[i][0]] > shortest[a[i][1]]
                            ? shortest[a[i][0]]
                            : shortest[a[i][1]];
    if (costmin < need && costmin + a[i][2] > need &&
        need <= costmax + a[i][2] - need + costmin)
      ans++;
    if (costmax < need && costmax + a[i][2] > need &&
        need < costmin + a[i][2] - need + costmax)
      ans++;
  }
  printf("%d", ans);
}
