#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 100;
long long dis[MAXN], par[MAXN], n, m, c, l, ans;
vector<pair<long long, long long> > adj[MAXN];
set<pair<long long, long long> > s;
pair<long long, long long> pr;
void Dij(long long x) {
  dis[x] = 0;
  for (long long i = 1; i <= n; i++) {
    s.insert(make_pair(dis[i], i));
  }
  while (s.size() > 0) {
    pr = *s.begin();
    long long y = pr.second;
    long long d = pr.first;
    s.erase(pr);
    for (long long i = 0; i < adj[y].size(); i++) {
      if (dis[adj[y][i].first] > d + adj[y][i].second) {
        s.erase(make_pair(dis[adj[y][i].first], adj[y][i].first));
        dis[adj[y][i].first] = d + adj[y][i].second;
        s.insert(make_pair(dis[adj[y][i].first], adj[y][i].first));
        par[adj[y][i].first] = y;
      }
    }
  }
}
int main() {
  fill(par, par + MAXN, 1e18);
  fill(dis, dis + MAXN, 1e18);
  cin >> n >> m >> c;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    adj[x].push_back(make_pair(y, w));
    adj[y].push_back(make_pair(x, w));
  }
  Dij(c);
  cin >> l;
  for (long long i = 1; i <= n; i++) {
    if (dis[i] == l) {
      ans++;
    } else if (dis[i] < l) {
      for (long long j = 0; j < adj[i].size(); j++) {
        if (par[adj[i][j].first] == i) {
          if (dis[i] + adj[i][j].second > l) {
            ans++;
          }
        } else if (par[i] != adj[i][j].first) {
          if (dis[i] + dis[adj[i][j].first] + adj[i][j].second > 2 * l &&
              dis[i] + adj[i][j].second > l) {
            ans++;
          } else if (dis[i] + dis[adj[i][j].first] + adj[i][j].second ==
                         2 * l &&
                     i < adj[i][j].first && dis[i] + adj[i][j].second > l) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
