#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 5;
int dis[N], n, m, s, ans = 0, l, w, j;
bool mark[N];
set<pair<int, int> > heap;
vector<pair<int, int> > e[N];
vector<pair<int, pair<int, int> > > edge;
int main() {
  cin >> n >> m >> s;
  s--;
  int t1, t2, t3;
  for (int i = 0; i < m; i++) {
    cin >> t1 >> t2 >> t3;
    t1--, t2--;
    e[t1].push_back(pair<int, int>(t3, t2));
    e[t2].push_back(pair<int, int>(t3, t1));
    edge.push_back(pair<int, pair<int, int> >(t1, pair<int, int>(t2, t3)));
  }
  cin >> l;
  mark[s] = true;
  dis[s] = 0;
  for (int i = 0; i < e[s].size(); i++) {
    heap.insert(pair<int, int>(e[s][i].first, e[s][i].second));
  }
  for (int i = 0; i < n - 1; i++) {
    while (heap.size() && mark[(*(heap.begin())).second])
      heap.erase(*(heap.begin()));
    pair<int, int> cur = *(heap.begin());
    mark[cur.second] = true;
    dis[cur.second] = cur.first;
    for (int j = 0; j < e[cur.second].size(); j++) {
      pair<int, int> nu = e[cur.second][j];
      if (!mark[nu.second])
        heap.insert(pair<int, int>(cur.first + nu.first, nu.second));
    }
  }
  for (int i = 0; i < n; i++)
    if (dis[i] == l) ans++;
  for (int k = 0; k < edge.size(); k++) {
    int i = edge[k].first;
    j = edge[k].second.first;
    w = edge[k].second.second;
    if (dis[i] < l && w > l - dis[i] && 2 * l <= dis[i] + dis[j] + w) {
      ans++;
    }
    if (dis[j] < l && w > l - dis[j] && 2 * l <= dis[i] + dis[j] + w &&
        w - (l - dis[i]) != l - dis[j]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
