#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, s;
  long long int m, l;
  cin >> n >> m >> s;
  int v, u, w;
  map<int, map<int, int> > graph;
  for (long long int a = 0; a < m; a++) {
    cin >> v >> u >> w;
    graph[v][u] = w;
    graph[u][v] = w;
  }
  cin >> l;
  queue<int> Q;
  vector<int> distance;
  distance.assign(n + 1, INT_MAX);
  int top;
  Q.push(s);
  distance[s] = 0;
  map<int, int>::iterator itm;
  while (!Q.empty()) {
    top = Q.front();
    Q.pop();
    for (itm = graph[top].begin(); itm != graph[top].end(); itm++) {
      if (distance[top] + itm->second < distance[itm->first]) {
        distance[itm->first] = distance[top] + itm->second;
        Q.push(itm->first);
      }
    }
  }
  long long int silos = 0;
  map<int, map<int, int> > roads;
  map<int, map<int, int> >::iterator itm1;
  int dis;
  for (itm1 = graph.begin(); itm1 != graph.end(); itm1++) {
    if (distance[itm1->first] == l) {
      silos++;
    } else if (distance[itm1->first] < l) {
      for (itm = itm1->second.begin(); itm != itm1->second.end(); itm++) {
        dis = distance[itm1->first] + itm->second;
        if (dis > l) {
          roads[itm1->first][itm->first] = l - distance[itm1->first];
        }
      }
    }
  }
  for (itm1 = roads.begin(); itm1 != roads.end(); itm1++) {
    for (itm = itm1->second.begin(); itm != itm1->second.end(); itm++) {
      if (itm->second != 0) {
        if (roads[itm->first][itm1->first] == 0) {
          dis = (graph[itm1->first][itm->first] - itm->second) +
                distance[itm->first];
          if (dis >= l) {
            silos = silos + 1;
          }
        } else {
          if (roads[itm1->first][itm->first] + roads[itm->first][itm1->first] ==
              graph[itm1->first][itm->first]) {
            silos = silos + 1;
          } else if (roads[itm1->first][itm->first] +
                         roads[itm->first][itm1->first] <
                     graph[itm1->first][itm->first]) {
            silos = silos + 2;
          }
          roads[itm->first][itm1->first] = 0;
        }
        itm->second = 0;
      }
    }
  }
  cout << silos << endl;
  return 0;
}
