1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <ctime>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 500;
const int MAXM = 500;

#define FOR(i, n) for(int i = 0, __n = n; i < __n; i++)
using para = pair<int, int>;

int n, m;
para e[MAXM], e2[MAXM];
vector<int> rem;

// int hits[5][MAXN];
int shuffler[MAXN];
int reshuffle = 0;


long long CLOCK_LIM = 90000000;
long long runs = 0;

int bestsofar = 1000;
int bestcount = 0;
int calc(int torem) {
  if (runs++ >= CLOCK_LIM) return n;
  int degs[MAXN];
  int degsr[MAXN];
  
  FOR(i, n) degs[i] = 0;
  FOR(i, n) degsr[i] = 0;
  FOR(i, rem.size()) {
    degsr[rem[i]] = degs[rem[i]] = -1;
  }

  FOR(i, m) {
    if (degs[e[i].first] == -1 || degs[e[i].second] == -1) {
      continue;
    }
    degs[e[i].second] = max(degs[e[i].second], degs[e[i].first] + 1);
  }
  for(int i = m - 1; i >= 0; i--) {
    if (degsr[e2[i].first] == -1 || degsr[e2[i].second] == -1) {
      continue;
    }
    degsr[e2[i].first] = max(degsr[e2[i].first], degsr[e2[i].second] + 1);
  }

  // int tot = *max_element(degs.begin(), degs.end());
  int tot = *max_element(degs, degs + n);
  
  if (torem == 0) {
    // if (tot < bestsofar) {
    //   bestsofar = tot;
    //   bestcount = 1;
    // } else if (tot == bestsofar) {
    //   bestcount ++;
    // }
    // memo[hash] = tot;
    return tot;
  }
  
  int solo[MAXN];
  if (torem == 1) {
    FOR(i, tot+1) solo[i] = -1;
    FOR(i, n) {
      if (degs[i] + degsr[i] == tot) {
        // cerr << i << ") " << degs[i] << endl;
        if (solo[degs[i]] == -1) {
          solo[degs[i]] = i;
        } else {
          solo[degs[i]] = -2;
        }
      }
    }
    // FOR(i, tot+1) {
    //   cerr << solo[i] << endl;
    // }
  }

  int best = tot;
  // int maxes = 0;

  FOR(j, n) {
    int i = shuffler[j];
    if (degs[i] + degsr[i] == tot) {
      if (torem == 1) {
        if (solo[degs[i]] != i) {
          continue;
        }
      }
      // maxes++;
      rem.push_back(i);
      int v = calc(torem - 1);
      // cerr << i << ") " << v << endl;
      best = min(best, v);
      rem.pop_back();
    }
  }
  // hits[torem][maxes]++;
  // if (maxes > 45) cerr << "M" << torem << " " << maxes << endl;
  return best;
}

bool reversed (const para & i, const para & j) {
  return (i.second < j.second);
}

int main() {
  ios_base::sync_with_stdio(0);
  int k;
  cin >> n >> m >> k;

  vector<para> E;
  FOR(i, m) {
    int a, b;
    cin >> a >> b;
    e2[i] = e[i] = para(a-1, b-1);
  }
  FOR(i, n) shuffler[i] = i;
  sort(e, e + m);
  sort(e2, e2 + m, reversed);
  // random_shuffle(shuffler, shuffler + n);
  cout << calc(k) + 1 << endl;
  // cerr << runs << " " << n << " " << m << " " << k << endl;
  // cerr << "BEST" << bestcount << " " << bestsofar << endl;
  // cerr << "H:" << hit << " M:" << miss << endl;

  // for(int i = 0; i<n && i<80;i++) {
  //   cerr << setw(3) << i << ":";
  //   for(int j = 0; j <= k; j++) {
  //     cerr << setw(10) << hits[j][i];
  //   }
  //   cerr << endl;
  // }
  return 0;
}