#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e17;
const double DINF = numeric_limits<double>::max();
const int ITER = 300;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const int MAXN = 1e5 + 10;
int n, m, s, l;
long long d[MAXN];
vector<pair<int, int> > g[MAXN];
vector<pair<int, pair<int, int> > > edgelist;
void solve() {
  cin >> n >> m >> s;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
    edgelist.push_back({w, {u, v}});
  }
  cin >> l;
  for (int i = 0; i < MAXN; i++) d[i] = LINF;
  d[s] = 0;
  set<pair<long long, int> > MS;
  MS.insert({0, s});
  for (int i = 1; i <= n; i++) {
    if (i == s) continue;
    MS.insert({LINF, i});
  }
  for (int i = 0; i < n; i++) {
    auto v = *MS.begin();
    MS.erase(v);
    for (auto u : g[v.second]) {
      if (d[v.second] + u.second < d[u.first]) {
        MS.erase({d[u.first], u.first});
        d[u.first] = d[v.second] + u.second;
        MS.insert({d[u.first], u.first});
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] == l) ans++;
  for (auto e : edgelist) {
    int w = e.first, u = e.second.first, v = e.second.second;
    if (d[u] < l && l - d[u] < w && w - (l - d[u]) + d[v] > l) ans = ans + 1;
    if (d[v] < l && l - d[v] < w && w - (l - d[v]) + d[u] > l) ans = ans + 1;
    if (d[u] < l && d[v] < l && d[u] + d[v] + w == 2 * l) ans = ans + 1;
  }
  cout << ans << endl;
}
int main() {
  cout << setprecision(12) << fixed;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
