#include "bits/stdc++.h"

using namespace std;
using ll = long long;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

//誤差修正用
const double EPS = 1e-8;

//円周率
const double PI = acos(-1);

//double型の値が等しいか
inline bool eq(double a, double b) { return fabs(b - a) < EPS; }

//点に関する構造体
struct Point
{
	double x, y;

	Point() {}

	Point(double x, double y) : x(x), y(y) {}

	//加減、スカラー倍、乗算など
	Point operator+(const Point &b) const { return Point(x + b.x, y + b.y); }

	Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }

	Point operator*(const double b) const { return Point(x * b, y * b); }

	Point operator*(const Point &b) const { return Point(x * b.x - y * b.y, x * b.y + y * b.x); }

	Point operator/(const double b) const { return Point(x / b, y / b); }

	bool operator<(const Point &b) const { return x != b.x ? x < b.x : y < b.y; }

	bool operator==(const Point &b) const { return eq(x, b.x) && eq(y, b.y); }

	//大きさの二乗
	double norm() { return x * x + y * y; }

	//逆正接（x軸正方向からの反時計回り回転角）
	double arg() { return atan2(x, y); }

	//大きさ
	double abs() { return sqrt(norm()); }

	//反時計回りにθ回転
	Point rotate(double theta) { return Point(cos(theta) * x - sin(theta) * y, sin(theta) * x + cos(theta) * y); }

	//反時計回りにπ/2回転
	Point rotate90() { return Point(-y, x); }

	friend ostream &operator<<(ostream &os, Point &p) { return os << p.x << " " << p.y; }

	friend istream &operator>>(istream &is, Point &a) { return is >> a.x >> a.y; }
};

//外積
double cross(const Point &a, const Point &b)
{
	return a.x * b.y - a.y * b.x;
}

//内積
double dot(const Point &a, const Point &b)
{
	return a.x * b.x + a.y * b.y;
}

//直線に関する構造体
//直線が通る2点で表す
struct Line
{
	Point a, b;

	Line() {};

	Line(Point a, Point b) : a(a), b(b) {};

	friend ostream &operator<<(ostream &os, Line &p) { return os << "(" << p.a.x << "," << p.a.y << ") to (" << p.b.x << "," << p.b.y << ")"; }

	friend istream &operator>>(istream &is, Line &a) { return is >> a.a.x >> a.a.y >> a.b.x >> a.b.y; }
};

//多角形
typedef vector< Point > Polygon;

//3点の位置関係を判定
int ccw(const Point &a, Point b, Point c)
{
	b = b - a, c = c - a;

	//a→bで反時計回りの方向にc
	if (cross(b, c) > EPS) return +1;

	//a→bで時計回りの方向にc
	if (cross(b, c) < -EPS) return -1;

	//c→a→bで一直線
	if (dot(b, c) < 0) return +2;

	//a→b→cで一直線
	if (b.norm() < c.norm()) return -2;

	//a→c→bで一直線
	return 0;
}

//2直線の平行判定
bool IsParallel(const Line& a, const Line& b) {
	return abs(cross(a.b - a.a, b.b - b.a)) < EPS;
}

//点集合（多角形）の凸包を求める
//Andrew's Monotone Chain
//O(NlogN)（ソート依存）
Polygon Convex_Hull(Polygon& p) {
	int n = p.size(), k = 0;
	if (n >= 3) {
		sort(p.begin(), p.end());
		vector< Point > ch(2 * n);
		for (int i = 0; i < n; ch[k++] = p[i++]) {
			while (k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
		}
		for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
			while (k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
		}
		ch.resize(k - 1);
		return ch;
	}
	else {
		return p;
	}
}

//2直線の交差判定
bool Intersect(const Line &l, const Line &m)
{
	return abs(cross(l.b - l.a, m.b - m.a)) > EPS || abs(cross(l.b - l.a, m.b - l.a)) < EPS;
}

//2直線の交点
Point Crosspoint(const Line &l, const Line &m)
{
	double A = cross(l.b - l.a, m.b - m.a);
	double B = cross(l.b - l.a, l.b - m.a);
	if (abs(A) < EPS && abs(B) < EPS) return m.a;
	return m.a + (m.b - m.a) * B / A;
}

#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]

//凸多角形の切断
//直線に対して左側にある部分（交点を含む）を返す
Polygon ConvexCut(Polygon &U, Line l)
{
	Polygon ret;
	for (int i = 0; i < U.size(); i++) {
		Point now = curr(U, i), nxt = next(U, i);
		if (ccw(l.a, l.b, now) != -1) ret.push_back(now);
		if (ccw(l.a, l.b, now) * ccw(l.a, l.b, nxt) < 0) {
			ret.push_back(Crosspoint(Line(now, nxt), l));
		}
	}
	return (ret);
}

//多角形の面積
//ただし返り値は求めたい値の2倍になっている
double Area2(const Polygon &p)
{
	double A = 0;
	for (int i = 0; i < p.size(); ++i) {
		A += cross(p[i], p[(i + 1) % p.size()]);
	}
	return A;
}

int main() {
    int n;
    int poi;
    Polygon m;
    Point z;
    cin >> n;
    m.assign(n,z);
    for(int i = 0;i<n;i++) {
        cin >> m[i].x >> m[i].y;
    }
    m = Convex_Hull(m);
    cout << m.size() << endl;
    poi = 0;
    for(int i=0;i<m.size();i++) { 
        if(m[i].y > m[i+1].y) poi=i+1;
        else break;
    }
    for(int i = poi;i<m.size();i++) {
        cout <<  m[i].x << " "<<  m[i].y << endl;
    }
    for(int i = 0;i<poi;i++) {
        cout <<  m[i].x << " "<<  m[i].y << endl;
    }
    return 0;
}


Measured memory_bytes: 5264