#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

typedef long double Real;
#define EPS (1e-10)
#define EQ(a,b) (abs(a-b) < EPS)
#define LE(a,b) (EQ(a,b) || a < b)
#define GE(a,b) (EQ(a,b) || b < a)

#define PCR Point const &
#define SCR Segment const &
#define LCR Line const &

struct Point {
    Real x, y;
    explicit Point (Real x_ = 0, Real y_ = 0);
    explicit Point (Real x_);
    Point operator + (PCR p) const;
    Point operator - (PCR p) const;
    Point operator * (PCR p) const;
    Point operator / (PCR p) const;
    Point operator * (Real k) const;
    Point operator / (Real k) const;
    bool operator < (PCR p) const;
    bool operator == (PCR p) const;
};
Real dot(PCR p, PCR q) { return p.x * q.x + p.y * q.y; }
Real cross(PCR p, PCR q) { return p.x * q.y - p.y * q.x; }
Real norm(PCR p){ return dot(p,p); }
Real abs(PCR p){ return sqrt(norm(p)); }
Point inv(PCR p){ return Point(p.x,-p.y) / abs(p); }
Real arg(PCR p){ return atan2(p.y,p.x); }
ostream & operator << (ostream & os, PCR p){ return os << "(" << p.x << "," << p.y << ")"; }
Point::Point (Real x_, Real y_) : x(x_), y(y_) {}
Point::Point (Real x_) : x(x_), y(0) {}
Point Point::operator + (PCR p) const { return Point(x + p.x, y + p.y); }
Point Point::operator - (PCR p) const { return Point(x - p.x, y - p.y); }
Point Point::operator * (PCR p) const { return Point(x*p.x - y*p.y, x*p.y + y*p.x); }
Point Point::operator / (PCR p) const { return Point(*this) * inv(p); }
Point Point::operator * (Real k) const { return Point(x * k, y * k); }
Point Point::operator / (Real k) const { return Point(x / k, y / k); }
bool Point::operator < (PCR p) const { return std::abs(x - p.x) < EPS ? x < p.x : y < p.y; }
bool Point::operator == (PCR p) const { return EQ(*this,p); }
bool comp_x(PCR p, PCR q){ return !EQ(p.x,q.x) ? p.x < q.x : p.y < q.y; }
bool comp_y(PCR p, PCR q){ return !EQ(p.y,q.y) ? p.y < q.y : p.x < q.x; }
struct Segment {
    Point p[2];
    Point operator [] (int k) { return p[k]; }
    const Point & operator [] (int k) const { return p[k]; }
};

struct Line {
    Point p[2];
    Point operator [] (int k) { return p[k]; }
    const Point & operator [] (int k) const { return p[k]; }
};

struct Circle {
    Point p; Real r;
};

typedef vector<Point> Polygon;

enum {
    CCW = +1,
    CW = -1,
    BACK = +2,
    FRONT = -2,
    ON = 0
};
int ccw(PCR p0, PCR p1, PCR p2){
    Point a = p1 - p0;
    Point b = p2 - p0;
    if(cross(a,b) > EPS) return CCW;
    if(cross(a,b) < -EPS) return CW;
    if(dot(a,b) < -EPS) return BACK;
    if(norm(a) < norm(b)) return FRONT;
    return ON;
}

Polygon andrewScan(Polygon ps){
    int N = ps.size(), k = 0;
    sort(all(ps),comp_x);
    Polygon res(N*2);
    for(int i=0; i<N; i++) {
        while(k>=2 && ccw(res[k-2], res[k-1], ps[i])==CW) k--;
        res[k++] = ps[i];
    }
    int t = k+1;
    for(int i=N-2; i>=0; i--) {
        while(k>=t && ccw(res[k-2], res[k-1], ps[i])==CW) k--;
        res[k++] = ps[i];
    }
    res.resize(k-1);
    return res;
}

signed main(){
    int n = 0;
    cin >> n;
    Polygon p(n);
    rep(i,n){
        Real x,y;
        scanf("%Lf %Lf",&x,&y);
        p[i] = Point(x,y);
    }
    Polygon q = andrewScan(p);
    printf("%d\n", (int)q.size());
    int d = min_element(all(q), comp_y) - q.begin();
    rep(i,q.size()){
        int x = q[(i+d)%q.size()].x;
        int y = q[(i+d)%q.size()].y;
        printf("%d %d\n", x,y);
    }
};

Measured memory_bytes: 13472