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>
namespace quick {
namespace in {
inline char getc() {
  static char buf[1 << 21], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read(char *s) {
  *s = getc();
  while (isspace(*s)) {
    *s = getc();
    if (*s == EOF) return 0;
  }
  while (!isspace(*s) && *s != EOF) {
    s++;
    *s = getc();
  }
  *s = '\0';
  return 1;
}
template <typename Type>
inline int read(Type &x) {
  x = 0;
  bool k = false;
  char c = getc();
  while (!isdigit(c)) {
    k |= (c == '-');
    c = getc();
    if (c == EOF) return 0;
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getc();
  }
  x *= (k ? -1 : 1);
  return 1;
}
template <typename Type, typename... Args>
inline int read(Type &&t, Args &&...args) {
  return read(t) + read(args...);
}
}  // namespace in
using in::read;
namespace out {
char buf[1 << 21];
int p1 = -1;
const int p2 = (1 << 21) - 1;
inline void flush() {
  fwrite(buf, 1, p1 + 1, stdout);
  p1 = -1;
}
inline void putc(const char &c) {
  if (p1 == p2) flush();
  buf[++p1] = c;
}
inline void write(char *s) {
  while (*s != '\0') putc(*s), s++;
}
inline void write(const char *s) {
  while (*s != '\0') putc(*s), s++;
}
template <typename Type>
inline void write(Type x) {
  static char buf[30];
  int p = -1;
  if (x < 0) {
    putc('-');
    x = -x;
  }
  if (x == 0)
    putc('0');
  else
    for (; x; x /= 10) buf[++p] = x % 10 + 48;
  for (; p != -1; p--) putc(buf[p]);
}
inline void write(const char &c) { putc(c); }
template <typename Type, typename... Args>
inline void write(const Type &t, const Args &...args) {
  write(t);
  write(args...);
}
}  // namespace out
using out::flush;
using out::write;
template <typename Type>
inline Type max(const Type &a, const Type &b) {
  if (a < b) return b;
  return a;
}
template <typename Type>
inline Type min(const Type &a, const Type &b) {
  if (a < b) return a;
  return b;
}
template <typename Type>
inline void swap(Type &a, Type &b) {
  a ^= b ^= a ^= b;
}
template <typename Type>
inline Type abs(const Type &a) {
  return a >= 0 ? a : -a;
}
}  // namespace quick
using namespace quick;
const int maxn = 2e5 + 10, maxm = 3e5 + 10, inf = 0x3f3f3f3f;
int n, m, s;
using ll = long long;
const ll Inf = 0x3f3f3f3f3f3f3f3f;
struct Edge {
  int v, next;
  ll w;
  Edge(const int &v, const int &next, const ll &w) : v(v), next(next), w(w) {}
  Edge() {}
} e[maxm << 1];
int head[maxn], cnt;
inline void AddEdge(const int &u, const int &v, const ll &w) {
  e[++cnt] = Edge(v, head[u], w);
  head[u] = cnt;
}
std::vector<int> dag[2][maxn], tree[maxn];
int order[maxn], stamp, in_degree[maxn];
void TopoSort(const int &s = ::s) {
  static std::queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    order[++stamp] = u;
    for (const int &v : dag[0][u])
      if (!--in_degree[v]) q.push(v);
  }
}
ll d[maxn];
void Dijkstra(const int &s = ::s) {
  using pii = std::pair<ll, int>;
  static std::priority_queue<pii, std::vector<pii>, std::greater<pii> > q;
  static char vis[maxn];
  memset(d, 0x3f, sizeof d);
  memset(vis, 0x00, sizeof vis);
  d[s] = 0LL;
  q.push(std::make_pair(d[s], s));
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (!~vis[u]) continue;
    vis[u] = 0xff;
    for (int i(head[u]); i; i = e[i].next) {
      const int &v = e[i].v;
      if (d[u] + e[i].w < d[v]) {
        d[v] = d[u] + e[i].w;
        q.push(std::make_pair(d[v], v));
      }
    }
  }
}
int p[maxn][19], depth[maxn];
inline void GetPre(const int &u) {
  for (int i(1); i < 19; i++) p[u][i] = p[p[u][i - 1]][i - 1];
}
inline int lca(int x, int y) {
  if (depth[x] < depth[y]) swap(x, y);
  for (int i(18); ~i; i--)
    if (depth[p[x][i]] >= depth[y]) x = p[x][i];
  if (x == y) return x;
  for (int i(18); ~i; i--) {
    if (p[x][i] == p[y][i]) continue;
    x = p[x][i];
    y = p[y][i];
  }
  return p[x][0];
}
void BuildTree() {
  memset(p, 0xff, sizeof p);
  depth[s] = 1;
  for (int i(0); i < 19; i++) p[s][i] = s;
  for (int i(2); i <= stamp; i++) {
    const int &u = order[i];
    int father(dag[1][u][0]);
    for (const int &v : dag[1][u]) {
      if (v == dag[1][u][0]) continue;
      father = lca(father, v);
    }
    p[u][0] = father;
    tree[father].push_back(u);
    depth[u] = depth[father] + 1;
    GetPre(u);
  }
}
int size[maxn];
void Dfs(const int &u) {
  size[u] = 1;
  for (const int &v : tree[u]) {
    Dfs(v);
    size[u] += size[v];
  }
}
int main(void) {
  read(n, m, s);
  for (int i(1); i <= m; i++) {
    int u, v;
    ll w;
    read(u, v, w);
    AddEdge(u, v, w);
    AddEdge(v, u, w);
  }
  Dijkstra();
  for (int u(1); u <= n; u++)
    for (int i(head[u]); i; i = e[i].next) {
      const int &v = e[i].v;
      if (d[u] == Inf || d[v] == Inf) continue;
      if (d[u] + e[i].w == d[v]) {
        dag[0][u].push_back(v);
        in_degree[v]++;
        dag[1][v].push_back(u);
      }
    }
  TopoSort();
  BuildTree();
  Dfs(s);
  int ans = 0;
  for (int i(1); i <= n; i++) {
    if (i == s) continue;
    ans = max(ans, size[i]);
  }
  write(ans, '\n');
  flush();
  return 0;
}
