#include <bits/stdc++.h>
using namespace std;
int dist[1000005];
bool visited[1000005];
bool vis[1000000];
int n, m, s, l;
vector<pair<int, int> > Mp[1000005];
struct edge {
  int x, y, z;
  edge(int a, int b, int c) { x = a, y = b, z = c; }
};
vector<edge> edgelist;
struct data {
  int first, second;
  data(int b, int a) {
    second = a;
    first = b;
  }
  bool operator<(const data& p) const { return first > p.first; }
};
void dijkstra() {
  std::priority_queue<data> q;
  for (int i = 1; i <= n; i++) {
    dist[i] = 1000000000;
    visited[i] = false;
  }
  dist[s] = 0;
  q.push(data(0, s));
  while (!q.empty()) {
    data current = q.top();
    q.pop();
    if (!visited[current.second]) {
      visited[current.second] = true;
      for (int j = 0; j < Mp[current.second].size(); j++) {
        pair<int, int> temp = Mp[current.second][j];
        if (dist[current.second] + temp.second < dist[temp.first]) {
          dist[temp.first] = dist[current.second] + temp.second;
          q.push(data(dist[temp.first], temp.first));
        }
      }
    }
  }
}
int main() {
  cin >> n >> m >> s;
  int x, y, w, c = 0;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> w;
    Mp[x].push_back(make_pair(y, w));
    Mp[y].push_back(make_pair(x, w));
    edgelist.push_back(edge(x, y, w));
  }
  cin >> l;
  dijkstra();
  for (int i = 0; i < m; i++) {
    int n1 = edgelist[i].x, n2 = edgelist[i].y;
    if ((!vis[n1] && (dist[n1] == l))) {
      c++;
      vis[n1] = true;
    }
    if ((!vis[n2] && (dist[n2] == l))) {
      c++;
      vis[n2] = true;
    }
    if (dist[n1] < l && dist[n2] < l && edgelist[i].z > l - dist[n1] &&
        edgelist[i].z > l - dist[n2] &&
        (l - dist[n1] + l - dist[n2] == edgelist[i].z)) {
      c++;
    } else {
      if (dist[n1] < l && edgelist[i].z > l - dist[n1] &&
          ((edgelist[i].z - (l - dist[n1])) + dist[n2]) > l) {
        c++;
      }
      if (dist[n2] < l && edgelist[i].z > l - dist[n2] &&
          ((edgelist[i].z - (l - dist[n2])) + dist[n1]) > l) {
        c++;
      }
    }
  }
  cout << c << endl;
  return 0;
}
