#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

ifstream fin("joke.in");
ofstream fout("joke.out");

struct paar {
	int len, ok;
	paar () {};
	paar (int a, int b) {len = a; ok = b;}
	bool operator< (const paar &a) const{ 
		return (ok < a.ok);
	}
} memo[2000], null;

int tab[1100][1100];
int N;

struct paar doit (int k) {
	//cout << N << k << endl;
	if (k>=N) return paar (0,0);
	if (memo[k].ok != -1) return memo[k];
	
	struct paar &ret = memo[k];
	//ret = paar(0,0);
	for (int i=1; i<=N-k; i++) {
		struct paar vas = doit (k+i);
		if (vas.ok + tab[k][i] > ret.ok) {
			ret.ok = vas.ok + tab[k][i];
			ret.len = i;
		}
	}
	return ret;
}

int vordseid[2000];

int main () {
	fin >> N;
	int i;
	for (i=0; i<N; i++) {
		int ees, taga;
		fin >> ees >> taga;
		if (N-ees-taga>=0)
			tab[ees][N-ees-taga] ++;
	}
	for (i=0; i<2000; i++) memo[i] = paar(-1,-1);
	null = paar(-1,-1);
	
	doit(0);
	//for (i=0; i<=N; i++) cout << i << " " << memo[i].len << " " << memo[i].ok << endl;

	int kus = 0;
	while (kus < N) {
		//for (i=0; i<memo[kus].len; i++)
		vordseid[kus] = memo[kus].len;
		kus += memo[kus].len;
	}

	fout << N-memo[0].ok;
	fin.close();
	fin.open("joke.in");
	fin >> N;
	for (i=0; i<N; i++) {
		int ees, taga, keskel;
		fin >> ees >> taga;
		keskel = N-ees-taga;
		if (vordseid[ees] != keskel) {
			fout << " " << (i+1);
		}
	}
	fout << endl;

	return 0;
}
