#include <bits/stdc++.h>   using namespace std;   int n, m, s, ans, tot, tot1, tot2;   int siz[200010], du[200010], dep[200010], fa[200010][18];   int q[200010], head[200010], head1[200010], head2[200010], power[18];   bool v[200010];   long long dis[200010];   struct Map {     int r, len, next;   } line[600010];   struct Map_sp {     int r, next;   } line1[600010], line2[600010];   void add(int x, int y, int len) {     tot++;     line[tot].r = y;     line[tot].len = len;     line[tot].next = head[x];     head[x] = tot;   }   void add1(int x, int y) {     tot1++;     line1[tot1].r = y;     line1[tot1].next = head1[x];     head1[x] = tot1;   }   void add2(int x, int y) {     tot2++;     line2[tot2].r = y;     line2[tot2].next = head2[x];     head2[x] = tot2;   }   void spfa() {     for (int i = 1; i <= n; i++) dis[i] = 1e18;     int hd = 0, tl = 0;     q[tl++] = s, dis[s] = 0, v[s] = true;     while (hd != tl) {       int x = q[hd];       for (int i = head[x]; i; i = line[i].next) {         int rx = line[i].r, len = line[i].len;         if (dis[x] + len < dis[rx]) {           dis[rx] = dis[x] + len;           if (!v[rx]) {             v[rx] = true;             q[tl++] = rx;             if (tl == 200010) tl = 0;           }         }       }       v[x] = false;       hd++;       if (hd == 200010) hd = 0;     }   }   void build(int x) {     v[x] = true;     for (int i = head[x]; i; i = line[i].next) {       int rx = line[i].r;       if (dis[x] + line[i].len == dis[rx]) {         add1(x, rx), add2(rx, x);         du[rx]++;         if (!v[rx]) build(rx);       }     }   }   void dfs(int x) {     siz[x] = 1;     for (int i = head[x]; i; i = line[i].next) {       int rx = line[i].r;       dfs(rx);       siz[x] += siz[rx];     }     if (x != s) ans = max(ans, siz[x]);   }   int lca(int x, int y) {     if (dep[x] < dep[y]) swap(x, y);     int tmp = dep[x] - dep[y];     for (int i = 0; power[i] <= tmp; i++)       if (tmp & power[i]) x = fa[x][i];     if (x == y) return x;     for (int i = 17; i >= 0; i--)       if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];     return fa[x][0];   }   void topo() {     int hd = 1, tl = 0;     q[++tl] = s, dep[s] = 1;     while (hd <= tl) {       int x = q[hd];       for (int i = head1[x]; i; i = line1[i].next) {         int rx = line1[i].r;         du[rx]--;         if (!du[rx]) {           q[++tl] = rx;           int LCA = 0;           for (int j = head2[rx]; j; j = line2[j].next)             if (!LCA)               LCA = line2[j].r;             else               LCA = lca(LCA, line2[j].r);           add(LCA, rx, 0);           fa[rx][0] = LCA;           dep[rx] = dep[LCA] + 1;           for (int j = 1; j <= 17; j++) fa[rx][j] = fa[fa[rx][j - 1]][j - 1];         }       }       hd++;     }   }   inline int read() {     int x = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) ch = getchar();     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x;   }   int main() {     power[0] = 1;     for (int i = 1; i <= 17; i++) power[i] = power[i - 1] << 1;     n = read(), m = read(), s = read();     for (int i = 1; i <= m; i++) {       int u = read(), v = read(), w = read();       add(u, v, w), add(v, u, w);     }     spfa();     build(s);     tot = 0;     memset(head, 0, sizeof(head));     topo();     dfs(s);     printf( %d , ans);     return 0;   }