#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1000 * 1010;
vector<long long> cost[maxn];
vector<pair<long long, long long> > edj;
vector<long long> edjc;
vector<long long> adj[maxn];
long long d[maxn];
long long mark[maxn];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    qu;
bool mid(long long a, long long b, long long c) {
  return min(a, c) < b && b < max(a, c);
}
long long n, m, s, l;
long long t1, t2, t3;
long long v;
long long dis;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> s;
  for (int i = 0; i < m; ++i) {
    cin >> t1 >> t2 >> t3;
    t1--;
    t2--;
    adj[t1].push_back(t2);
    adj[t2].push_back(t1);
    cost[t1].push_back(t3);
    cost[t2].push_back(t3);
    edj.push_back(pair<int, int>(t1, t2));
    edjc.push_back(t3);
  }
  cin >> l;
  s--;
  qu.push(pair<int, int>(0, s));
  for (int i = 0; i < n; ++i) d[i] = 1000 * 1000 * 1000;
  while (!qu.empty()) {
    v = qu.top().second;
    dis = qu.top().first;
    qu.pop();
    if (mark[v]) continue;
    mark[v] = true;
    d[v] = dis;
    for (int i = 0; i < (int)adj[v].size(); ++i)
      qu.push(pair<int, int>(dis + cost[v][i], adj[v][i]));
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    if (d[i] == l) ans++;
  for (int i = 0; i < m; ++i) {
    long long miv = edj[i].first;
    long long mav = edj[i].second;
    long long l1 = -1, l2 = -1;
    if (d[miv] > d[mav]) swap(miv, mav);
    if (l - d[miv] > 0 && d[miv] + edjc[i] > l) {
      ans++;
      l1 = (l - d[miv]);
    }
    if (l - d[mav] > 0 && d[mav] + edjc[i] > l) {
      ans++;
      l2 = (l - d[mav]);
    }
    if (l1 != -1 && l - d[mav] >= edjc[i]) ans--;
    if (l2 != -1 && l - d[miv] >= edjc[i]) ans--;
    if (l1 == -1 || l2 == -1) continue;
    if (l1 + l2 == edjc[i]) {
      ans--;
    }
    if (l1 + l2 > edjc[i]) {
      ans -= 2;
    }
  }
  cout << ans << endl;
  return 0;
}
