#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > g[300005];
bool u[300005];
long long int arr[300005];
long long int l;
long long int x[300005], y[300005], w[300005];
set<pair<long long int, long long int> > s;
int main() {
  long long int i, j, n, m, ans = 0, a, b, c, index = 1;
  cin >> n >> m >> j;
  for (i = 0; i <= n; i++) {
    arr[i] = INT_MAX;
  }
  for (i = 0; i < m; i++) {
    cin >> x[i] >> y[i] >> w[i];
    g[x[i]].push_back(make_pair(y[i], w[i]));
    g[y[i]].push_back(make_pair(x[i], w[i]));
  }
  cin >> l;
  s.insert(make_pair(0, j));
  arr[j] = 0;
  while (!s.empty()) {
    long long int k = s.begin()->second;
    s.erase(s.begin());
    for (i = 0; i < g[k].size(); i++) {
      if (arr[g[k][i].first] > arr[k] + g[k][i].second) {
        s.erase(make_pair(arr[g[k][i].first], g[k][i].first));
        arr[g[k][i].first] = arr[k] + g[k][i].second;
        s.insert(make_pair(arr[g[k][i].first], g[k][i].first));
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (arr[i] == l) ans++;
  }
  for (i = 0; i < m; i++) {
    long long int d1 = arr[x[i]], d2 = arr[y[i]];
    long long int k1 = l - d1;
    long long int k2 = l - d2;
    if (k1 > 0 && w[i] > k1 && (w[i] - k1 + d2 >= l)) ans++;
    if (k2 > 0 && w[i] > k2 && (w[i] - k2 + d1 > l)) ans++;
  }
  cout << ans;
}
