A country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to any other one by these roads. According to some Super Duper Documents, Berland is protected by the Super Duper Missiles. The exact position of the Super Duper Secret Missile Silos is kept secret but Bob managed to get hold of the information. That information says that all silos are located exactly at a distance l from the capital. The capital is located in the city with number s.

The documents give the formal definition: the Super Duper Secret Missile Silo is located at some place (which is either city or a point on a road) if and only if the shortest distance from this place to the capital along the roads of the country equals exactly l.

Bob wants to know how many missile silos are located in Berland to sell the information then to enemy spies. Help Bob.

Input

The first line contains three integers n, m and s (2 ≤ n ≤ 105, <image>, 1 ≤ s ≤ n) — the number of cities, the number of roads in the country and the number of the capital, correspondingly. Capital is the city no. s. 

Then m lines contain the descriptions of roads. Each of them is described by three integers vi, ui, wi (1 ≤ vi, ui ≤ n, vi ≠ ui, 1 ≤ wi ≤ 1000), where vi, ui are numbers of the cities connected by this road and wi is its length. The last input line contains integer l (0 ≤ l ≤ 109) — the distance from the capital to the missile silos. It is guaranteed that: 

  * between any two cities no more than one road exists; 
  * each road connects two different cities; 
  * from each city there is at least one way to any other city by the roads. 

Output

Print the single number — the number of Super Duper Secret Missile Silos that are located in Berland.

Examples

Input

4 6 1
1 2 1
1 3 3
2 3 1
2 4 1
3 4 1
1 4 2
2


Output

3


Input

5 6 3
3 1 1
3 2 1
3 4 1
3 5 1
1 2 6
4 5 8
4


Output

3

Note

In the first sample the silos are located in cities 3 and 4 and on road (1, 3) at a distance 2 from city 1 (correspondingly, at a distance 1 from city 3).

In the second sample one missile silo is located right in the middle of the road (1, 2). Two more silos are on the road (4, 5) at a distance 3 from city 4 in the direction to city 5 and at a distance 3 from city 5 to city 4.
import java.util.*;

import java.io.*;;

public class E {

	static ArrayList<Integer> primes; // generated by sieve

	/*
	 * 1. Generating a list of prime factors of N
	 */
	static ArrayList<Long> primeFactors(Long N) // O(sqrt(N) / ln sqrt(N))
	{
		ArrayList<Long> factors = new ArrayList<Long>(); // take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while (p * p <= N) {
			if (N % p == 0)
				factors.add((long) p);
			while (N % p == 0) {
				N /= p;
			}
			if (idx + 1 == primes.size())
				break;
			p = primes.get(++idx);
		}

		if (N != 1) // last prime factor may be > sqrt(N)
			factors.add(N); // for integers whose largest prime factor has a power of 1
		return factors;
	}

	static int[] isComposite;

	static void sieve(int N) // O(N log log N)
	{
		isComposite = new int[N + 1];
		isComposite[0] = isComposite[1] = 1; // 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) // can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) // can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if (1l * i * i <= N)
					for (int j = i * i; j <= N; j += i) // j = i * 2 will not affect performance too much, may alter in
														// modified sieve
						isComposite[j] = 1;
			}
	}

	static ArrayList<Integer> arr;
	static int n;
	static int m;
	static int k1;
	static int k2;
	static int[] memo;

//	static int dp(int idx) {
//		if (idx == a.length) {
//			return 0;
//		}
//		if (memo[idx] != -1)
//			return memo[idx];
//		int max = 0;
//		int gcd=
//		if (l == 0) {
//			if (c == k1)
//				max += dp(idx + 1, t, 1, 1);
//			else {
//				max += (dp(idx + 1, t + 1, c + 1, l) + dp(idx + 1, t, 1, 1)) % 100000000;
//			}
//		} else {
//			if (c == k2)
//				max += dp(idx + 1, t + 1, 1, 0);
//			else {
//				max += (dp(idx + 1, t, c + 1, l) + dp(idx + 1, t + 1, 1, 0)) % 100000000;
//			}
//		}
//		return memo[idx][t][c][l] = max;
//	}

	static long[] cum;

	public static void main(String[] args) throws NumberFormatException, IOException, InterruptedException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int s = Integer.parseInt(st.nextToken()) - 1;
		g = new ArrayList[n];
		adjList = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
			adjList[i] = new ArrayList<>();
		}
		t = new triple[m];
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(br.readLine());
			int u = Integer.parseInt(st.nextToken()) - 1;
			int v = Integer.parseInt(st.nextToken()) - 1;
			int w = Integer.parseInt(st.nextToken());
			g[u].add(new pair(v, w));
			g[v].add(new pair(u, w));
			adjList[u].add(new Edge(v, w));
			adjList[v].add(new Edge(u, w));
			t[i] = new triple(u, v, w);
		}
		V = n;
		int l = Integer.parseInt(br.readLine());
		vis = new boolean[n];
		pw.println(dijkstra(s, l));
		pw.flush();
		pw.close();

	}

	static class Edge implements Comparable<Edge> {
		int node, cost;

		Edge(int a, int b) {
			node = a;
			cost = b;
		}

		public int compareTo(Edge e) {
			return cost - e.cost;
		}
	}

	static final int INF = (int) 1e9; // don't increase, avoid overflow
	static ArrayList<Edge>[] adjList;
	static int V;
	static triple[] t;

	static int dijkstra(int S, int l) // O(E log E)
	{
		int[] d = new int[V];
		Arrays.fill(d, INF);
		double c = 0;
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		d[S] = 0;
		pq.add(new Edge(S, 0)); // may add more in case of MSSP (Mult-Source)
		while (!pq.isEmpty()) {
			Edge cur = pq.remove();
			if (cur.cost > d[cur.node]) // lazy deletion
				continue;
			for (Edge nxt : adjList[cur.node]) {

				if (cur.cost + nxt.cost < d[nxt.node]) {
					pq.add(new Edge(nxt.node, d[nxt.node] = cur.cost + nxt.cost));
				}
			}
		}

//		boolean[] vis = new boolean[V];
		for (int j = 0; j < d.length; j++) {
			if (d[j] == l)
				c++;
		}
		for (triple x : t) {
			if (d[x.x] < l && l - d[x.y] < x.z && x.z - (l - d[x.x]) + d[x.y] > l)
				c++;
			if (d[x.y] < l && l - d[x.x] < x.z && x.z - (l - d[x.y]) + d[x.x] > l)
				c++;
			if (d[x.x] < l && d[x.y] < l && d[x.y] + d[x.x] + x.z == 2 * l)
				c++;
		}

//		System.out.println(Arrays.toString(dist));
		return (int) c;
	}

	static ArrayList<pair>[] g;
	static boolean[] vis;

	static int bfs(int s, int l) {
		Queue<pair> q = new LinkedList<pair>();
		q.add(new pair(s, l));
		vis[s] = true;
		int c = 0;
		while (!q.isEmpty()) {
			pair p = q.remove();
			int u = p.x;
			int r = p.y;
			if (r == 0)
				c++;
			else if (r > 0) {
				for (pair p1 : g[u]) {
					int v = p1.x;
					int w = p1.y;
					if (!vis[v]) {
						vis[v] = true;
						q.add(new pair(v, r - w));
					}
				}
			}
		}
		return c;
	}

	static int[] a;

	static long reverse(String r) {
		String s = "";
		for (int i = 0; i < r.length(); i++) {
			if (r.charAt(i) == '1')
				s += '0';
			else
				s += '1';
		}
		return Long.parseLong(s, 2);
	}

	static long dis(int x, int y, int z, int w) {
		return (x - z) * (x - z) + (y - w) * (y - w);
	}

	static int gcd(int a, int b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}

	}

	static class triple implements Comparable<triple> {
		int x;
		int y;
		int z;

		public triple(int a, int b, int c) {
			x = a;
			y = b;
			z = c;
		}

		@Override
		public int compareTo(triple o) {
			// TODO Auto-generated method stub
			return y - o.y;
		}
	}
}
