#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edge[100000];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
int dist[100000];
int ncity, nroad, s, l;
map<pair<pair<int, int>, int>, bool> marked;
int main() {
  scanf("%d %d %d", &ncity, &nroad, &s);
  --s;
  for (int i = 0; i < nroad; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --a;
    --b;
    edge[a].push_back(make_pair(b, c));
    edge[b].push_back(make_pair(a, c));
  }
  scanf("%d", &l);
  for (int i = 0; i < ncity; ++i) dist[i] = 1000000005;
  dist[s] = 0;
  q.push(make_pair(0, s));
  while (!q.empty()) {
    int u = q.top().second;
    int d = q.top().first;
    q.pop();
    if (dist[u] < d) continue;
    for (int i = 0; i < (int)edge[u].size(); ++i) {
      int v = edge[u][i].first;
      int e = edge[u][i].second;
      if (d + e < dist[v]) {
        dist[v] = d + e;
        q.push(make_pair(dist[v], v));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < ncity; ++i) {
    if (dist[i] == l)
      ++ans;
    else if (dist[i] < l) {
      for (int j = 0; j < (int)edge[i].size(); ++j)
        if (dist[i] + edge[i][j].second > l) {
          int left = l - dist[i];
          int mini = dist[i] + left;
          if (dist[edge[i][j].first] + edge[i][j].second - left < mini)
            continue;
          if (!marked.count(make_pair(make_pair(i, edge[i][j].first), left))) {
            ++ans;
            marked[make_pair(make_pair(i, edge[i][j].first), left)] = 1;
            marked[make_pair(make_pair(edge[i][j].first, i),
                             edge[i][j].second - left)] = 1;
          }
        }
    }
  }
  printf("%d\n", ans);
}
