#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001LL int main(){ long long N,M,K; cin>>N>>M>>K; vector x(N),y(N); rep(i,M){ int a,b; cin>>a>>b; a--,b--; x[a] ++; y[b] ++; } long long ans = 0; long long num = 0; vector cost; rep(i,N){ if(x[i]>0){ num++; ans += max(0LL,K - y[i]); } else{ cost.push_back(max(0LL,K - y[i])); } } sort(cost.begin(),cost.end()); if(num < K+1){ rep(i,K+1 - num)ans += cost[i]; } cout<