#include <bits/stdc++.h>
using namespace std;
const int inf = 4e8;
template <typename T>
void print(T &v, int n = -1) {
  if (n < 0) n = v.size();
  for (int i = 0; i < n; i++) printf("%d ", v[i]);
  printf("\n");
}
void dijkstra(vector<pair<pair<int, int>, int> > edges, int n, int source,
              int l) {
  vector<int> dist(n + 1, inf), done(n + 1, 0);
  dist[source] = 0;
  vector<vector<pair<int, int> > > G(n + 1);
  for (int i = 0; i < edges.size(); i++) {
    int u = edges[i].first.first;
    int v = edges[i].first.second;
    int w = edges[i].second;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
  }
  set<pair<int, int> > s;
  for (int i = 1; i <= n; i++) s.insert(make_pair(dist[i], i));
  int ans = 0;
  while (not s.empty()) {
    auto it = s.begin();
    int d = it->first;
    int u = it->second;
    done[u] = true;
    for (auto edge : G[u]) {
      int v = edge.first;
      int w = edge.second;
      if (!done[v] && dist[v] > dist[u] + w) {
        auto iter = s.find(make_pair(dist[v], v));
        s.erase(iter);
        dist[v] = dist[u] + w;
        s.insert(make_pair(dist[v], v));
      }
      if (done[u] && done[v]) {
        int len = dist[u] + dist[v] + w;
        if (len == 2 * l)
          ans++;
        else if (len > 2 * l)
          ans += 2;
        if (dist[u] >= l) ans--;
        if (dist[v] >= l) ans--;
      }
    }
    s.erase(it);
  }
  for (int i = 1; i <= n; i++)
    if (dist[i] == l) ans++;
  cout << ans << endl;
}
int main() {
  int n, m, s, l;
  cin >> n >> m >> s;
  vector<pair<pair<int, int>, int> > edges(m);
  for (int i = 0; i < m; i++)
    cin >> edges[i].first.first >> edges[i].first.second >> edges[i].second;
  cin >> l;
  dijkstra(edges, n, s, l);
  return 0;
}
