#include <bits/stdc++.h>   using namespace std;   int n, m, k;   vector<int> v[1000010];   vector<int> vv;   bool visit[1000010] = {0};   int t, tt;   int res = 0;   void dfs(int x) {     visit[x] = 1;     t++;     for (int i = 0; i < v[x].size(); i++) {       int xi = v[x][i];       if (!visit[xi]) dfs(xi);     }   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--, y--;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 0; i < n; i++) {       if (!visit[i]) {         t = 0;         dfs(i);         vv.push_back(min(t, k));       }     }     if (k == 1) {       cout << max(0, (int)(vv.size() - 2));       return 0;     }     sort(vv.begin(), vv.end());     reverse(vv.begin(), vv.end());     tt = vv[0];     for (int i = 1; i < vv.size(); i++) {       if (tt)         tt += vv[i] - 2;       else {         tt++;         res++;       }     }     cout << res;     return 0;   }   