#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int INF = 1000000005;
priority_queue<pair<int, int> > q;
vector<pair<int, int> > E[N];
int d[N], n, st;
bool u[N];
void dij() {
  int i, x;
  for (i = 1; i <= n; i++) d[i] = INF;
  d[st] = 0;
  for (i = 1; i <= n; i++) {
    q.push(make_pair(-d[i], i));
  }
  while (!q.empty()) {
    pair<int, int> fr = q.top();
    q.pop();
    x = fr.second;
    if (u[x]) continue;
    u[x] = true;
    for (i = E[x].size() - 1; i >= 0; i--) {
      int j = E[x][i].first;
      if (d[j] > d[x] + E[x][i].second) {
        d[j] = d[x] + E[x][i].second;
        q.push(make_pair(-d[j], j));
      }
    }
  }
}
int main() {
  int m, i, j, a, b, c, l;
  scanf("%d%d%d", &n, &m, &st);
  while (m--) {
    scanf("%d%d%d", &a, &b, &c);
    E[a].push_back(make_pair(b, c));
    E[b].push_back(make_pair(a, c));
  }
  dij();
  int r = 0;
  scanf("%d", &l);
  for (i = 1; i <= n; i++) {
    if (d[i] == l) r++;
    if (d[i] >= l) continue;
    for (j = E[i].size() - 1; j >= 0; j--) {
      int x = E[i][j].first, y = E[i][j].second;
      if (d[i] + y > l) {
        int p = l - d[i];
        if (d[x] + y - p > l || (d[x] + y - p == l && x < i)) r++;
      }
    }
  }
  printf("%d\n", r);
  return 0;
}
