#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
	friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
	friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
	friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
	friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
	friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
	friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
	friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
	friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
	friend Point operator*(long double d, const Point& p1) { return p1 * d; }
	friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
	Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d; py *= d; return *this; }
	Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0, b = p2 - p0;
	if (crs(a, b) > 1e-10) return 1;
	if (crs(a, b) < -1e-10) return -1;
	if (dot(a, b) < -1e-10) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
vector<Point> convex_hull(vector<Point> v) {
	if (v.size() < 3) return v;
	sort(v.begin(), v.end());
	vector<Point> u = { v[0], v[1] }, l = { v[v.size() - 1], v[v.size() - 2] };
	for (int i = 2; i < v.size(); i++) {
		for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], v[i]) >= 0; n--) u.pop_back();
		u.push_back(v[i]);
	}
	for (int i = v.size() - 3; i >= 0; i--) {
		for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], v[i]) >= 0; n--) l.pop_back();
		l.push_back(v[i]);
	}
	reverse(l.begin(), l.end());
	for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);
	return l;
}
// ------ Main ------ //
int n, x, y; vector<Point> v;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d%d", &x, &y), v.push_back(Point(x, y));
	vector<Point> ret = convex_hull(v);
	int p = 0;
	for (int i = 1; i < ret.size(); i++) {
		if (ret[p].py > ret[i].py || (ret[p].py == ret[i].py && ret[p].px > ret[i].px)) {
			p = i;
		}
	}
	cout << ret.size() << endl;
	for (int i = p; i < p + ret.size(); i++) cout << ret[i % ret.size()].px << ' ' << ret[i % ret.size()].py << endl;
	return 0;
}

Measured memory_bytes: 15656