#include <bits/stdc++.h>
using namespace std;
constexpr long double pi{3.1415926535897932384};
constexpr long long mod{1000000007};
long long power(long long x, long long y) {
  long long res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
const long long maxn = 100005;
long long n, m, s, l, ans{0};
vector<pair<long long, long long>> g[maxn];
vector<long long> vis(maxn, 0);
vector<long long> dis(maxn, LLONG_MAX);
void dijkstra(long long start) {
  dis[start] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  pq.push({0, start});
  while (!pq.empty()) {
    long long cur = pq.top().second;
    long long cur_d = pq.top().first;
    pq.pop();
    if (cur_d > dis[cur]) {
      continue;
    }
    for (auto it : g[cur]) {
      if (cur_d + it.second < dis[it.first]) {
        dis[it.first] = cur_d + it.second;
        pq.push({dis[it.first], it.first});
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ;
  cin >> n >> m >> s;
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  cin >> l;
  dijkstra(s);
  for (long long i = 1; i <= n; i++) {
    if (dis[i] == l) {
      ans++;
    }
    if (dis[i] >= l) {
      continue;
    }
    for (auto x : g[i]) {
      long long a, b;
      a = x.first;
      b = x.second;
      if (dis[i] + b <= l) continue;
      if (dis[a] + b - (l - dis[i]) > l ||
          dis[a] + b - (l - dis[i]) == l && i < a) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
