#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, s, m, l;
vector<pair<int, int> > adj[N];
int dist[N], inq[N];
void spath() {
  for (int i = 1; i <= n; i++) dist[i] = INT_MAX;
  queue<int> q;
  q.push(s);
  dist[s] = 0;
  while (!q.empty()) {
    int top = q.front();
    q.pop();
    inq[top] = 0;
    for (auto xx : adj[top]) {
      if (dist[xx.first] == INT_MAX || dist[xx.first] > dist[top] + xx.second) {
        dist[xx.first] = dist[top] + xx.second;
        if (!inq[xx.first]) {
          q.push(xx.first);
          inq[xx.first] = 1;
        }
      }
    }
  }
}
int main() {
  int u, v, wt;
  scanf("%d%d%d", &n, &m, &s);
  ;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &wt);
    ;
    adj[u].push_back({v, wt});
    adj[v].push_back({u, wt});
  }
  scanf("%d", &l);
  ;
  spath();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = l - dist[i];
    if (dist[i] == l)
      ans++;
    else if (dist[i] < l)
      for (auto xx : adj[i]) {
        v = xx.first, wt = xx.second;
        if (dist[i] + wt <= l) continue;
        if (wt - tmp + dist[v] < l) continue;
        if (wt - tmp + dist[v] > l)
          ans++;
        else if (i < v)
          ans++;
      }
  }
  cout << ans;
  return 0;
}
