#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-10;
const int inf = 2000000000;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
inline bool checkBit(long long int n, long long int i) {
  return n & (1LL << i);
}
inline long long int setBit(long long int n, long long int i) {
  return n | (1LL << i);
  ;
}
inline long long int resetBit(long long int n, long long int i) {
  return n & (~(1LL << i));
}
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long int year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long int &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long int modMul(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long int modAdd(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long int modSub(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long int modPow(long long int b, long long int p) {
  long long int r = 1LL;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1LL;
  }
  return r;
}
inline long long int modDiv(long long int a, long long int b) {
  return modMul(a, modPow(b, 1000000007 - 2));
}
bool comp(const pair<int, int> &p1, const pair<int, int> &p2) {
  return p1.second < p2.second;
}
long long int converter(string a) {
  long long int i, mul = 1, r, t, ans = 0LL;
  if (a.length() == 0) return 0;
  for (i = a.length() - 1; i >= 0; i--) {
    t = a[i] - '0';
    r = t % 10;
    ans += (mul * r);
    mul = mul * 10;
  }
  return ans;
}
long long int d[100005], parent[100005], ans[100005], n, m, l, tot;
bool vis[100005];
bool mark[100005];
vector<pair<long long int, long long int> > adj[100005];
vector<pair<pair<long long int, long long int>, long long int> > edge;
void dijkstra(long long int start) {
  long long int u, v, w, i, c;
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int> >,
                 greater<pair<long long int, long long int> > >
      q;
  d[start] = 0;
  q.push(pair<long long int, long long int>(0, start));
  while (!q.empty()) {
    u = q.top().second;
    c = q.top().first;
    q.pop();
    for (i = 0; i < adj[u].size(); i++) {
      v = adj[u][i].first;
      w = adj[u][i].second;
      if (d[u] + w < d[v]) {
        d[v] = d[u] + w;
        parent[v] = u;
        q.push(pair<long long int, long long int>(d[v], v));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int i, k = 1, st, ans = 0;
  long long int x, y, w;
  cin >> n >> m >> st;
  for (i = 1; i <= n; i++) d[i] = (long long int)2e18;
  for (i = 0; i < m; i++) {
    cin >> x >> y >> w;
    if (x > y) swap(x, y);
    adj[x].push_back(pair<long long int, long long int>(y, w));
    adj[y].push_back(pair<long long int, long long int>(x, w));
    edge.push_back(make_pair(make_pair(x, y), w));
  }
  cin >> l;
  dijkstra(st);
  ;
  for (i = 1; i <= n; i++)
    ;
  tot = 0;
  for (i = 0; i < m; i++) {
    x = edge[i].first.first;
    y = edge[i].first.second;
    w = edge[i].second;
    if (d[x] == l && !mark[x]) {
      tot++;
      mark[x] = true;
    }
    if (d[y] == l && !mark[y]) {
      tot++;
      mark[y] = true;
    }
    if (d[x] < l && d[y] < l && d[x] + d[y] + w == 2 * l) {
      tot++;
    }
    if (d[x] + w > l && d[x] < l) {
      if ((d[y] + (w - l + d[x])) > l) tot++;
    }
    if (d[y] + w > l && d[y] < l) {
      if ((d[y] + w - l + d[x]) > l) tot++;
    }
  }
  cout << tot << '\n';
  return 0;
}
