#include "insects.h"
#include <vector>
#include <climits>
#include <iostream>
//#include <algobase.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
int rep[10001];
int n ;
bool in[10001];
int cnt[10001];
bool past[10001];
void joinn(int a, int b){
if(!in[a])move_inside(a);
if(!in[b])move_inside(b);
int k = press_button();
if(k == 2){
rep[b] = a;
cnt[a] ++ ;
cnt[b] = INT_MAX;
past[a] = true;
past[b] = true;
}
}
int min_cardinality(int N) {
for(int i = 0 ; i < N ; i ++){
rep[i] = i;
in[i] = false;
cnt[i] = 1;
past[i] = false;
}
n = N;
for(int i = 0 ; i < n-1 ; i ++){
if(past[i])continue;
for(int j = i+1 ; j < n ; j ++){
if(past[j])continue;
joinn(i, j);
move_outside(j);
}
move_outside(i);
}
int mini = INT_MAX;
for(int i = 0 ; i < n ; i ++){
//cout << "i = " << i << " " << cnt[i] << "\n";
mini = min(mini, cnt[i]);
}
return mini;
}