#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void dbg() { cout << "\n"; }
template<typename H, typename... T>
void dbg(H h, T... t) {
cout << h << " ";
dbg(t...);
}
#include "insects.h"
const int N = 2020;
int mark[N];
int min_cardinality(int n) {
vector<int> left;
int k = 0;
for (int i = 0; i < n; i++) {
move_inside(i);
if (press_button() > 1) {
move_outside(i);
left.push_back(i);
} else {
k++;
}
}
// for (auto x : left) dbg(x);
int ans = 1;
while (left.size()) {
int cnt = 0;
vector<int> tmp;
for (auto x : left) {
move_inside(x);
// dbg(x,press_button());
if (press_button() > ans+1) {
move_outside(x);
tmp.push_back(x);
} else {
cnt++;
}
}
// dbg(cnt,k,left.size());
if (cnt != k) break;
ans++;
left.clear();
for (auto x : tmp) left.push_back(x);
}
return ans;
}