It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since Bash wants to surprise his friends, he decides to send a Pikachu to each of them. Since there may be some cities which are not reachable from Bash's city, he only sends a Pikachu to those friends who live in a city reachable from his own city. He also wants to send it to them as soon as possible.

He finds out the minimum time for each of his Pikachus to reach its destination city. Since he is a perfectionist, he informs all his friends with the time their gift will reach them. A Pikachu travels at a speed of 1 meters per second. His friends were excited to hear this and would be unhappy if their presents got delayed. Unfortunately Team Rocket is on the loose and they came to know of Bash's plan. They want to maximize the number of friends who are unhappy with Bash.

They do this by destroying exactly one of the other n - 1 cities. This implies that the friend residing in that city dies, so he is unhappy as well.

Note that if a city is destroyed, all the roads directly connected to the city are also destroyed and the Pikachu may be forced to take a longer alternate route.

Please also note that only friends that are waiting for a gift count as unhappy, even if they die.

Since Bash is already a legend, can you help Team Rocket this time and find out the maximum number of Bash's friends who can be made unhappy by destroying exactly one city.

Input

The first line contains three space separated integers n, m and s (2 ≤ n ≤ 2·105, <image>, 1 ≤ s ≤ n) — the number of cities and the number of roads in the Himalayan region and the city Bash lives in.

Each of the next m lines contain three space-separated integers u, v and w (1 ≤ u, v ≤ n, u ≠ v, 1 ≤ w ≤ 109) denoting that there exists a road between city u and city v of length w meters.

It is guaranteed that no road connects a city to itself and there are no two roads that connect the same pair of cities.

Output

Print a single integer, the answer to the problem.

Examples

Input

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


Output

2


Input

7 11 2
1 2 5
1 3 5
2 4 2
2 5 2
3 6 3
3 7 3
4 6 2
3 4 2
6 7 3
4 5 7
4 7 7


Output

4

Note

In the first sample, on destroying the city 2, the length of shortest distance between pairs of cities (3, 2) and (3, 4) will change. Hence the answer is 2.
#include <bits/stdc++.h>
using namespace std;
struct IO_Tp {
  const static long long _I_Buffer_Size = 2 << 22;
  char _I_Buffer[_I_Buffer_Size], *_I_pos = _I_Buffer;
  const static long long _O_Buffer_Size = 2 << 22;
  char _O_Buffer[_O_Buffer_Size], *_O_pos = _O_Buffer;
  IO_Tp() { fread(_I_Buffer, 1, _I_Buffer_Size, stdin); }
  ~IO_Tp() { fwrite(_O_Buffer, 1, _O_pos - _O_Buffer, stdout); }
  IO_Tp &operator>>(long long &res) {
    long long f = 1;
    while (!isdigit(*_I_pos) && (*_I_pos) != '-') ++_I_pos;
    if (*_I_pos == '-') f = -1, ++_I_pos;
    res = *_I_pos++ - '0';
    while (isdigit(*_I_pos)) res = res * 10 + (*_I_pos++ - '0');
    res *= f;
    return *this;
  }
  IO_Tp &operator<<(long long n) {
    if (n < 0) *_O_pos++ = '-', n = -n;
    static char _buf[10];
    char *_pos = _buf;
    do *_pos++ = '0' + n % 10;
    while (n /= 10);
    while (_pos != _buf) *_O_pos++ = *--_pos;
    return *this;
  }
  IO_Tp &operator<<(char ch) {
    *_O_pos++ = ch;
    return *this;
  }
} IO;
const long long N = 200005, INF = 0x3f3f3f3f3f3f3f3f;
long long d[N], sz[N], f[N][20];
long long dis[N];
bool vst[N];
vector<long long> es[N], tree[N];
void add(long long u, long long v) {
  tree[u].push_back(v);
  d[v] = d[u] + 1, f[v][0] = u;
  for (long long i = 1; i < 20; i++) f[v][i] = f[f[v][i - 1]][i - 1];
}
long long LCA(long long x, long long y) {
  if (d[x] < d[y]) swap(x, y);
  for (long long i = 19; i >= 0; i--)
    if (d[f[x][i]] >= d[y]) x = f[x][i];
  if (x == y) return x;
  for (long long i = 19; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
void build(long long u) {
  if (vst[u]) return;
  vst[u] = 1;
  long long fa = 0;
  for (auto x : es[u]) build(x);
  for (auto x : es[u])
    if (!fa)
      fa = x;
    else
      fa = LCA(fa, x);
  add(fa, u);
}
void dfs(long long u) {
  sz[u] = (dis[u] != INF);
  for (auto v : tree[u])
    if (v != f[u][0]) dfs(v), sz[u] += sz[v];
}
long long n, m, s;
struct edge {
  long long t, w;
  edge(long long t_, long long w_) { t = t_, w = w_; }
};
vector<edge> G[N];
struct node {
  long long id, d;
  bool operator<(const node &x) const { return d > x.d; }
};
void dijkstra(long long s) {
  priority_queue<node> q;
  memset(dis, 0x3f, sizeof(dis));
  dis[s] = 0;
  q.push((node){s, 0});
  for (node cur; !q.empty();) {
    cur = q.top();
    q.pop();
    long long u = cur.id;
    if (cur.d > dis[u]) continue;
    for (auto x : G[u])
      if (dis[x.t] > dis[u] + x.w)
        dis[x.t] = dis[u] + x.w, q.push((node){x.t, dis[x.t]});
  }
}
int main() {
  IO >> n >> m >> s;
  for (long long i = 1, u, v, w; i <= m; i++)
    IO >> u >> v >> w, G[u].push_back(edge(v, w)), G[v].push_back(edge(u, w));
  dijkstra(s);
  for (long long u = 1; u <= n; u++)
    for (auto v : G[u])
      if (dis[v.t] == dis[u] + v.w) es[v.t].push_back(u), d[v.t]++;
  for (long long i = 1; i <= n; i++)
    if (!d[i]) es[i].push_back(n + 1);
  for (long long i = 1; i <= n; i++)
    if (!vst[i]) build(i);
  dfs(n + 1);
  long long ans = 0;
  for (long long i = 1; i <= n; i++)
    if (i != s) ans = max(ans, sz[i]);
  IO << ans << '\n';
  return 0;
}
