#include <bits/stdc++.h>
using namespace std;
int n, m, s, l;
int u, v, w;
vector<int> edge[100005], cost[100005];
int dis[100005];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
int main() {
  scanf("%d%d%d", &n, &m, &s);
  s--;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    u--;
    v--;
    edge[u].push_back(v);
    cost[u].push_back(w);
    edge[v].push_back(u);
    cost[v].push_back(w);
  }
  memset(dis, 100, sizeof(dis));
  dis[s] = 0;
  q.push(make_pair(0, s));
  while (!q.empty()) {
    int vert = q.top().second;
    int cd = q.top().first;
    q.pop();
    if (dis[vert] != cd) continue;
    for (int i = 0; i < edge[vert].size(); i++) {
      int e = edge[vert][i];
      if (dis[e] > dis[vert] + cost[vert][i]) {
        dis[e] = dis[vert] + cost[vert][i];
        q.push(make_pair(dis[e], e));
      }
    }
  }
  scanf("%d", &l);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (dis[i] == l) {
      ans++;
      continue;
    }
    if (dis[i] > l) continue;
    for (int j = 0; j < edge[i].size(); j++) {
      int e = edge[i][j];
      if (dis[i] + cost[i][j] > l) {
        int rem = l - dis[i];
        int other = dis[e] + cost[i][j] - rem;
        if (other < l) continue;
        if (other == l && e < i) continue;
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
