#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;
constexpr double EPS = 1e-10;
constexpr double PI = 3.14159265358979;

/* geometry libarary */

// a > 0 : +1, a == 0 : 0, a < 0 : -1
int sgn(const double a) {return (a < - EPS ? -1: (a > EPS ? 1: 0));}

/* 2d Point class */
struct Point {
    double x,y;
    constexpr Point(double x = 0.0,double y = 0.0) :x(x),y(y) {}

    Point operator+() const {return *this;}
    Point operator-() const {return Point(-x,-y);}

    constexpr Point &operator+=(const Point &q) {x += q.x;y += q.y;return *this;}
    constexpr Point &operator-=(const Point &q) {x -= q.x;y -= q.y;return *this;}
    constexpr Point &operator*=(double a) {x *= a;y *= a;return *this;}
    constexpr Point &operator/=(double a) {x /= a;y /= a;return *this;}
    
    constexpr Point operator+(const Point &q) const {return Point(*this) += q;}
    constexpr Point operator-(const Point &q) const {return Point(*this) -= q;}
    constexpr Point operator*(double a) const  {return Point(*this) *= a;}
    constexpr Point operator/(double a) const {return Point(*this) /= a;}

    inline bool operator<(const Point&q) const {return (sgn(x - q.x) != 0 ? sgn(x - q.x) < 0 : sgn(y - q.y) < 0);}
    inline bool operator>(const Point&q) const {return (sgn(x - q.x) != 0 ? sgn(x - q.x) > 0 : sgn(y - q.y) > 0);}
    inline bool operator==(const Point&q) const {return (sgn(x - q.x) == 0 && sgn(y - q.y) == 0);}

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

constexpr double dot(const Point &p,const Point &q) {return p.x * q.x + p.y * q.y;}
constexpr double cross(const Point &p,const Point &q) {return p.x * q.y - q.x * p.y;}
constexpr double norm(const Point &p) {return dot(p,p);}
inline double length(const Point &p) {return sqrt(norm(p));}
inline double dist(const Point &p,const Point &q) {return length(p - q);}
constexpr double sgn_area(const Point &p,const Point &q,const Point &r) {return cross(q - p,r - p)/2.0;}
constexpr double area(const Point &p,const Point &q,const Point &r) {return abs(sgn_area(p,q,r));}
inline Point normalized(const Point &p) {Point x = p/length(p);return x;}
inline Point rotation(const Point &p,double arg) {return Point(cos(arg) * p.x - sin(arg) * p.y,sin(arg) * p.x + cos(arg) * p.y);}
inline double angle(const Point &p) {return atan2(p.y,p.x);}

/*ab bc __/: +1
  ab bc --\: -1
  abc   ---: +2
  acb   ---: -2
  bac   ---:  0  */
int iSP(const Point &a,const Point &b,const Point &c) { 
    if (sgn(cross(b - a,c - a)) > 0) return 1;
    if (sgn(cross(b - a,c - a)) < 0) return -1;
    if (sgn(dot(b - a,c - b)) > 0) return 2;
    if (sgn(dot(a - b,c - a)) > 0) return -2;
    return 0;
}
//error point: changed depending on the problem
const Point error_point(INF,INF);

/* 2d Line(or Segment or Ray) class */
//2d Line class
struct Line {
    Point P,Q;
    constexpr Line(const Point &P,const Point &Q):P(P),Q(Q) {}
    constexpr Point vec() const {return Q - P;}
};
using Segment = Line;
using Ray = Line;

Point lineIntersection(const Line &l1,const Line &l2) {
    if (sgn(cross(l1.vec(),l2.vec())) == 0) return error_point;
    return l1.P + l1.vec() * abs(cross(l2.Q - l1.P,l2.vec())/cross(l1.vec(),l2.vec()));
}
/*
Point segmenIntersection(const Segment &s1,const Segment &s2) {
}
*/
double distance(const Point &p,const Line &l) {
    return abs(cross(l.vec(),p - l.P)/length(l.vec()));
}

int main() {
    int N; cin >> N;
    vector<Point> P(N);
    rep(i,N) cin >> P[i];

    sort(P.begin(),P.end());
    vector<int> lower_idx = {0,1};
    int sz = 0;
    for (int i = 2;i < N;++i) {
        while (iSP(P[lower_idx[sz]],P[lower_idx[sz + 1]],P[i]) == -1) {
            lower_idx.pop_back();
            --sz;
            if (sz < 0) {
                break;
            }
        }
        lower_idx.push_back(i);
        ++sz;
    }
    lower_idx.pop_back();

    vector<int> upper_idx = {N - 1,N - 2};
    sz = 0;
    for (int i = N - 3;i >= 0;--i) {
        while (iSP(P[upper_idx[sz]],P[upper_idx[sz + 1]],P[i]) == -1) {
            upper_idx.pop_back();
            --sz;
            if (sz < 0) {
                break;
            }
        }
        upper_idx.push_back(i);
        ++sz;
    }
    upper_idx.pop_back();
    vector<Point> ans;
    rep(i,lower_idx.size()) ans.push_back(P[lower_idx[i]]);
    rep(i,upper_idx.size()) ans.push_back(P[upper_idx[i]]);

    sz = ans.size();
    int idx = 0;
    Point p(INF,INF);
    rep(i,sz) {
        if (sgn(p.y - ans[i].y) != 0) {
            if (sgn(p.y - ans[i].y) > 0) {
                p = ans[i];
                idx = i;
            }
        } else {
            if (sgn(p.x - ans[i].x) > 0) {
                p = ans[i];
                idx = i;
            }
        }
    }
    cout << sz << '\n';
    int cnt = 0;
    for (int i = idx;cnt < sz;++i,i%=sz) {
        ++cnt;
        cout << ans[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 6680