#include <bits/stdc++.h>
using namespace std;
struct str {
  int q, cost;
  str(int _q = 0, int _cost = 0) {
    q = _q;
    cost = _cost;
  }
  bool operator<(const str &two) const { return cost > two.cost; }
};
struct edge {
  int u, v, cost;
  edge(int _u = 0, int _v = 0, int _cost = 0) { u = _u, v = _v, cost = _cost; }
};
vector<str> adj[(100000 + 10)];
int n, m, s;
int len;
int u, v, cost;
int dis[(100000 + 10)];
vector<edge> all;
int main() {
  cin >> n >> m >> s;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> cost;
    all.push_back(edge(u, v, cost));
    adj[u].push_back(str(v, cost));
    adj[v].push_back(str(u, cost));
  }
  cin >> len;
  for (int i = 1; i <= n; i++) dis[i] = 1000000000;
  dis[s] = 0;
  priority_queue<str> pq;
  pq.push(str(s, 0));
  while (!pq.empty()) {
    str v = pq.top();
    pq.pop();
    int node = v.q;
    for (int i = 0; i < adj[node].size(); i++) {
      int u = adj[node][i].q;
      int cost = adj[node][i].cost;
      if (dis[node] + cost < dis[u]) {
        dis[u] = dis[node] + cost;
        pq.push(str(u, dis[u]));
      }
    }
  }
  int out = 0;
  for (int i = 1; i <= n; i++)
    if (dis[i] == len) out++;
  int one, two;
  for (int i = 0; i < all.size(); i++) {
    u = all[i].u;
    v = all[i].v;
    cost = all[i].cost;
    if (dis[u] < len && len < dis[u] + cost &&
        cost - (len - dis[u]) + dis[v] > len)
      out++;
    if (dis[v] < len && len < dis[v] + cost &&
        cost - (len - dis[v]) + dis[u] > len)
      out++;
    if (dis[v] < len && dis[u] < len && dis[u] + dis[v] + cost == 2 * len)
      out++;
  }
  cout << out << endl;
  return 0;
}
