#include <iostream>
#include <algorithm>
#include <utility>
#include <stack>

using namespace std;
int n,x,y;
int ans=1;
int Q[100000+10];

pair<int,int> P[100000+10];
int cal_cross(pair<int, int> a, pair<int, int> b, pair<int, int> c){
	return (b.second-a.second)*(c.first-a.first)-(b.first-a.first)*(c.second-a.second);
}

int main() {
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> x >> y;
		P[i] = make_pair(y,x);
	}
	sort(P,P+n);
	Q[0] = 0;
	for (int i=1; i<n; i++){
		while ((ans>=2) && cal_cross(P[Q[ans-2]],P[Q[ans-1]],P[i])<0){
			ans--;
		}
		Q[ans++] = i;
	}
	for (int i=n-2; i>=0; i--){
		while ((ans>=2) && cal_cross(P[Q[ans-2]],P[Q[ans-1]],P[i])<0){
			ans--;
		}
		Q[ans++] = i;
	}
	cout << ans-1 << endl;
	for (int i=0; i<ans-1; i++){
		cout << P[Q[i]].second << ' ' << P[Q[i]].first << endl;
	}
}