#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e9 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
inline void debug_vi(vector<int> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void debug_vll(vector<long long> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void print_case(int tn) { cout << "Case #" << tn << ": "; }
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxpq = priority_queue<T>;
const int nax = 1e5 + 5;
vector<pair<int, int>> g[nax];
vector<pair<int, pair<int, int>>> es;
int n, m, s, dist[nax], l;
void dijkstra() {
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    dist[i] = INF;
  }
  dist[s] = 0;
  minpq<pair<int, int>> pq;
  pq.push({dist[s], s});
  int d, v, b, c;
  while (!pq.empty()) {
    tie(d, v) = pq.top();
    pq.pop();
    if (dist[v] < d) continue;
    for (auto itr : g[v]) {
      tie(b, c) = itr;
      if (dist[b] > dist[v] + c) {
        dist[b] = dist[v] + c;
        pq.push({dist[b], b});
      }
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t clk = clock();
  cin >> n >> m >> s;
  s--;
  int a, b, c;
  for (long long i = (long long)(0); i < (long long)(m); i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    if (a > b) swap(a, b);
    g[a].push_back({b, c});
    g[b].push_back({a, c});
    es.push_back({c, {a, b}});
  }
  cin >> l;
  dijkstra();
  int res = 0;
  for (long long i = (long long)(0); i < (long long)(n); i++)
    res += (dist[i] == l);
  for (long long i = (long long)(0); i < (long long)(m); i++) {
    c = es[i].first;
    tie(a, b) = es[i].second;
    int pd = -1;
    if (dist[a] < l && dist[a] + c > l) {
      int ad = l - dist[a];
      int bd = c - ad;
      if (dist[b] + bd >= l) {
        res++;
        pd = ad;
      }
    }
    if (dist[b] < l && dist[b] + c > l) {
      int bd = l - dist[b];
      int ad = c - bd;
      if (dist[a] + ad >= l && ad != pd) {
        res++;
      }
    }
  }
  cout << res;
  cerr << "\n"
       << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC
       << "\n";
  return 0;
}
