#include <bits/stdc++.h>
using ll = long long;
struct Edge {
  int t;
  ll w;
  bool flag;
  Edge(int t, ll w, bool f) : t(t), w(w), flag(f) {}
  Edge() : t(0), w(0), flag(false) {}
};
using graph = std::vector<std::vector<Edge>>;
ll n, m, s, L;
graph g;
const ll INF = 1e18;
ll dijkstra() {
  std::vector<ll> d(n, INF), state(n, 0);
  std::priority_queue<std::pair<ll, ll>> pq;
  d[s] = 0LL;
  pq.emplace(-0, s);
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    ll u = p.second;
    state[u] = 2;
    if (d[u] < -p.first) continue;
    for (auto e : g[u]) {
      if (state[e.t] != 2) {
        if (d[e.t] > d[u] + e.w) {
          d[e.t] = d[u] + e.w;
          state[e.t] = 1;
          pq.emplace(-d[e.t], e.t);
        }
      }
    }
  }
  ll ans = 0LL, offset = 0LL;
  for (int i = 0; i < n; i++) {
    if (d[i] == L) {
      ans++;
    }
    for (int j = 0; j < g[i].size(); j++) {
      if (d[i] < L && L < d[i] + g[i][j].w) {
        if ((L - d[i]) + (L - d[g[i][j].t]) == g[i][j].w) {
          ans++;
          offset++;
        } else if ((L - d[i]) < d[g[i][j].t] + g[i][j].w - L) {
          ans++;
        } else if ((L - d[g[i][j].t]) < d[i] + g[i][j].w - L) {
          ans++;
        }
      }
    }
  }
  return ans - offset / 2;
}
int main() {
  std::cin >> n >> m >> s;
  s--;
  g.resize(n);
  for (int i = 0; i < m; i++) {
    ll v, u, w;
    std::cin >> v >> u >> w;
    v--;
    u--;
    g[v].emplace_back(u, w, false);
    g[u].emplace_back(v, w, false);
  }
  std::cin >> L;
  std::cout << dijkstra() << std::endl;
  return 0;
}
