func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 2;   long long int i, j, n, m, s, ans = 0, cnt = 0;   vector<pair<long long int, long long int> > nf;   vector<long long int> graph[maxn];   bool foundd[maxn];   void dfs(long long int u, bool found[]) {     if (!foundd[u]) ++ans;     found[u] = true;     vector<long long int>::iterator it;     for (it = graph[u].begin(); it != graph[u].end(); ++it) {       if (!found[*it]) dfs(*it, found);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m >> s;     bool found[5200], isreachable[5200];     for (i = 0; i < m; ++i) {       long long int u, v;       cin >> u >> v;       graph[u].push_back(v);     }     memset(found, false, sizeof(found));     dfs(s, found);     for (i = 1; i <= n; ++i) foundd[i] = found[i];     for (i = 1; i <= n; ++i) {       if (!foundd[i]) {         bool found1[5001];         memset(found1, false, sizeof(found1));         ans = 0;         dfs(i, found1);         nf.push_back(make_pair(ans, i));       }     }     sort(nf.begin(), nf.end(), greater<pair<long long int, long long int> >());     for (i = 0; i < nf.size(); ++i) {       if (!foundd[nf[i].second]) {         bool found1[5001];         memset(found1, false, sizeof(found1));         dfs(nf[i].second, found1);         ++cnt;         for (j = 1; j <= n; ++j)           if (found1[j]) foundd[j] = true;       }     }     cout << cnt;   }   