#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

double cross_product (xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

vector<xy_t> convhull;
pii g[1000000];
xy_t cg[1000000];

int convexHull(int n) {
    sort(g, g + n);
    for (int i = 0; i < n; i++) {
        cg[i] = xy_t(g[i].first, g[i].second);
    }
    vector<xy_t> down;
    down.push_back(cg[0]);
    for (int i = 1; i < n; i++) {
        while (true) {
            if (down.size() == 1) {
                down.push_back(cg[i]);
                break;
            } else {
                xy_t a = down[down.size() - 2];
                xy_t b = down[down.size() - 1];
                double diff = cross_product(b - a, cg[i] - a);
                if (diff > -1 * eps) {
                    down.push_back(cg[i]);
                    break;
                } else {
                    down.pop_back();
                }
            }
        }
    }
    vector<xy_t> up;
    up.push_back(down[down.size() - 1]);
    for (int i = n - 2; i >= 0; i--) {
        while (true) {
            if (up.size() == 1) {
                up.push_back(cg[i]);
                break;
            } else {
                xy_t a = up[up.size() - 2];
                xy_t b = up[up.size() - 1];
                double diff = cross_product(b - a, cg[i] - a);
                if (diff > -1 * eps) {
                    up.push_back(cg[i]);
                    break;
                } else {
                    up.pop_back();
                }
            }
        }
    }
    int downlen = down.size();
    for (int i = 0; i < downlen; i++) {
        convhull.push_back(down[i]);
    }
    int uplen = up.size();
    for (int i = 1; i < uplen - 1; i++) {
        convhull.push_back(up[i]);
    }
    int num = downlen + uplen - 2;
    return num;
}

int main() {
    int n;
    cin >> n;
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        g[i] = pii(x, y);
    }
    int num = convexHull(n);
    int bottom = 0;
    int bottomy = convhull[0].imag();
    int len = convhull.size();
    for (int i = 1; i < len; i++) {
        if (convhull[i].imag() >= bottomy) {
            break;
        } else {
            bottomy = convhull[i].imag();
            bottom++;
        }
    }
    cout << num << endl;
    for (int i = bottom; i < len; i++) {
        cout << convhull[i].real() << " " << convhull[i].imag() << endl;
    }
    for (int i = 0; i < bottom; i++) {
        cout << convhull[i].real() << " " << convhull[i].imag() << endl;
    }
}



Measured memory_bytes: 8068