#include <bits/stdc++.h>
using namespace std;
int n, m, s, l;
vector<pair<int, int>> graph[100001];
int dist[100001];
int main() {
  scanf("%d %d %d", &n, &m, &s);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    graph[a].push_back({b, c});
    graph[b].push_back({a, c});
  }
  scanf("%d", &l);
  for (int i = 1; i <= n; ++i) {
    dist[i] = 1000000007;
  }
  dist[s] = 0;
  priority_queue<pair<int, int>> pq;
  pq.push({0, s});
  while (!pq.empty()) {
    int u = pq.top().second, w = -pq.top().first;
    pq.pop();
    if (dist[u] < w) continue;
    for (const auto& e : graph[u]) {
      if (dist[e.first] > dist[u] + e.second) {
        dist[e.first] = dist[u] + e.second;
        pq.push({-dist[e.first], e.first});
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (dist[i] == l) ++ans;
    for (const auto& e : graph[i]) {
      if (i >= e.first) continue;
      int df0 = l - dist[i];
      int df1 = l - dist[e.first];
      bool ok0 = false, ok1 = false;
      if (0 < df0 && df0 < e.second && l <= dist[e.first] + e.second - df0) {
        ++ans;
        ok0 = true;
      }
      if (0 < df1 && df1 < e.second && l <= dist[i] + e.second - df1) {
        ++ans;
        ok1 = true;
      }
      if (ok0 && ok1 && df0 + df1 == e.second) {
        --ans;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
