#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using u64 = uint_fast64_t; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
//////////////////////////////////////////////////////////////////////////////

// 精度が足りないときはlong double
using DD = double;
constexpr DD EPS = 1e-11;
const DD PI = acos(DD(-1));
inline int sgn(DD a) {return (a < -EPS) ? -1 : (a > EPS) ? 1 : 0;}

//点
struct Point {
    DD x, y;
    Point (DD x = 0, DD y = 0): x(x), y(y) {}

    Point operator+(const Point &p) const { return Point(*this) += p;}
    Point operator-(const Point &p) const { return Point(*this) -= p;}
    Point operator*(const Point &p) const { return Point(*this) *= p;}
    Point operator*(DD a) const { return Point(*this) *= a;}
    Point operator/(DD a) const { return Point(*this) /= a;}
    Point& operator+=(const Point &p) { x += p.x; y += p.y; return *this;}
    Point& operator-=(const Point &p) { x -= p.x; y -= p.y; return *this;}
    Point& operator*=(const Point &p) { DD u = x*p.x - y*p.y; DD v = x*p.y + y*p.x; x = u; y = v; return *this;}
    Point& operator*=(DD a) { x *= a; y *= a; return *this;}
    Point& operator/=(DD a) { x /= a; y /= a; return *this;}
    bool operator==(const Point &p) const { return !sgn(x - p.x) && !sgn(y - p.y);}
    bool operator!=(const Point &p) const { return sgn(x - p.x) || sgn(y - p.y);}
    bool operator<(const Point &p) const {
        if (sgn(x - p.x)) return sgn(x - p.x) < 0;
        return sgn(y - p.y) < 0;
    }
    friend istream& operator>>(istream& is, Point& p) { is >> p.x >> p.y; return is;}
    friend ostream& operator<<(ostream& os, const Point& p) { os << p.x << " " << p.y; return os;}

    DD norm() { return x*x + y*y;}
    DD abs() { return sqrt(norm());}
    DD arg() { return atan2(y,x);}
};

//ベクトル
using Vector = Point;

inline DD norm(const Vector &a) { return a.x * a.x + a.y * a.y;}
inline DD abs(const Vector &a) { return sqrt(norm(a));}
inline DD dot(const Vector &a, const Vector &b) { return a.x * b.x + a.y * b.y;}
inline DD cross(const Vector &a, const Vector &b) { return a.x * b.y - a.y * b.x;}
inline Point rot(const Point &p, DD ang) { return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) { return Point(-p.y, p.x);}
inline DD arg(const Vector &p) { return atan2(p.y, p.x);}
inline Vector polar(DD a, DD r) { return Point(cos(r) * a, sin(r) * a);}
//象限
int ort(const Point &a) {
    if (sgn(norm(a))) {
        if (sgn(a.y) > 0) return sgn(a.x) > 0 ? 1 : 2;
        return sgn(a.x) > 0 ? 4 : 3;
    }
    return 0;
}
bool xsort(const Point &a, const Point &b) {
    if (sgn(a.x - b.x)) return sgn(a.x - b.x) < 0;
    return sgn(a.y - b.y) < 0;
}
bool ysort(const Point &a, const Point &b) {
    if (sgn(a.y - b.y)) return sgn(a.y - b.y) < 0;
    return sgn(a.x - b.x) < 0;
}

bool argsortcross(const Point &a, const Point &b) {
    int ao = ort(a), bo = ort(b);
    if (ao != bo) return ao < bo;
    return sgn(cross(a,b)) > 0;
}

bool argsortatan2(const Point &a, const Point &b) {
    return sgn(atan2(b.y, b.x) - atan2(a.y, a.x)) > 0;
}

//線分
struct Segment {
    Point p1,p2;
    Segment() {};
    Segment(Point p1, Point p2) : p1(p1),p2(p2) {}
};

//直線
using Line = Segment;

// 円
struct Circle {
    Point c;
    DD r;
    Circle(){}
    Circle(Point c, DD r): c(c), r(r) {}
    friend istream& operator >>(istream& is, Circle& C) { is >> C.c >> C.r; return is;}
    friend ostream& operator <<(ostream& os, const Circle& C) { os << C.c << " " << C.r; return os;}
};

//多角形
using Polygon = vector<Point>;

//点の進行方向
int ccw(const Point &p0, const Point &p1, const Point &p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (sgn(cross(a,b)) > 0) return 1; //p0,p1から見てp2は左側(反時計回り)
    if (sgn(cross(a,b)) < 0) return -1; //p0,p1から見てp2は右側(時計回り)
    if (sgn(dot(a,b)) < 0) return 2; //p2-p0-p1の順に一直線上
    if (sgn(norm(b) - norm(a)) > 0) return -2; //p0-p1-p2の順に一直線上
    return 0; //p0-p2-p1の順に一直線上
}

//直線の交差判定 交差する場合1, 平行な場合0, 同一直線のとき-1
int intersectLP(const Vector &a, const Vector &b) {
    if (sgn(cross(a,b))) return 1;
    if (sgn(dot(a,b))) return 0;
    return -1;
} 
int intersectLP(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return intersectLP(p2-p1,p4-p3);}
int intersectLP(const Line &l1, const Line &l2) {return intersectLP(l1.p1,l1.p2,l2.p1,l2.p2);}

//直線の平行判定
bool isParallel(const Vector &a, Vector &b) {return intersectLP(a,b) <= 0;}
bool isParallel(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return intersectLP(p1,p2,p3,p4) <= 0;}
bool isParallel(const Line &l1, const Line &l2) {return intersectLP(l1,l2) <= 0;}

//直線の直交判定
bool isOrthogonal(const Vector &a, const Vector &b) {return !sgn(dot(a,b));}
bool isOrthogonal(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return isOrthogonal(p2-p1,p4-p3);}
bool isOrthogonal(const Line &l1, const Line &l2) {return isOrthogonal(l1.p1,l1.p2,l2.p1,l2.p2);}

//線分の交差判定
bool intersectSP(const Point &p1, const Point &p2, const Point &p3, const Point &p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);}
bool intersectSP(const Segment &s1, const Segment &s2) { return intersectSP(s1.p1, s1.p2, s2.p1, s2.p2);}

//直線と線分の交差判定
bool intersectLSP(const Line &l, const Segment &s) {return ccw(l.p1,l.p2,s.p1)*ccw(l.p1,l.p2,s.p2) <= 0;}

//直線と直線の交点
Point getCrossPointLP(const Line &l1, const Line &l2) {
    assert(intersectLP(l1,l2)==1);
    return l1.p1 + (l1.p2-l1.p1)*cross(l2.p1-l1.p1,l2.p2-l2.p1)/cross(l1.p2-l1.p1,l2.p2-l2.p1);
}

//線分と線分の交点
Point getCrossPointSP(const Segment &s1, const Segment &s2) {
    assert(intersectSP(s1,s2));
    return getCrossPointLP(s1,s2);
}

//射影
Point project(const Segment &s, const Point &p) {
    Vector base = s.p2 - s.p1;
    DD r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

//線対称
Point reflect(const Segment &s, const Point &p) {return p + (project(s,p) - p) * 2;}

//点と直線の距離
DD getDistanceLP(const Line &l, const Point &p) { return abs(cross(l.p2 - l.p1,p - l.p1) / abs(l.p2 - l.p1));}

//点と線分の距離
DD getDistanceSP(const Segment &s, const Point &p) {
    if (sgn(dot(s.p2 - s.p1,p - s.p1)) < 0) return abs(p - s.p1);
    if (sgn(dot(s.p1 - s.p2,p - s.p2)) < 0) return abs(p - s.p2);
    return getDistanceLP(s, p);
}

//直線と直線の距離
DD getDistanceLP(const Line &l1, const Line &l2) {
    if (intersectLP(l1,l2)) return 0;
    return getDistanceLP(l1,l2.p1);
}

//直線と線分の距離
DD getDistanceLSP(const Line &l, const Segment &s) {
    if (intersectLSP(l,s)) return 0;
    return min(getDistanceLP(l,s.p1),getDistanceLP(l,s.p2));
}

//線分と線分の距離
DD getDistanceSP(const Segment &s1, const Segment &s2) {
    if (intersectSP(s1, s2)) return 0;
    return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)});
}

//円と直線の交差判定
bool intersectLP(const Circle &c, const Line &l) { return sgn(getDistanceLP(l, c.c) - c.r) <= 0;}
//円と線分の交差判定
bool intersectSP(const Circle &c, const Segment &s) {
    return sgn(getDistanceSP(s,c.c) - c.r) <= 0 && sgn(max(abs(s.p1 - c.c),abs(s.p2 - c.c)) - c.r) >= 0;
}
//円と円の交差判定
int intersect(const Circle &c1, const Circle &c2) {
    if (sgn(abs(c1.c - c2.c) - (c1.r + c2.r)) > 0) return 4;     //2つの円が離れている場合
    if (!sgn(abs(c1.c - c2.c) - (c1.r + c2.r))) return 3;        //2つの円が外接する場合
    if (sgn(fabs(c1.r - c2.r) - abs(c1.c - c2.c)) > 0) return 0; //一方がもう一方を内包する場合
    if (!sgn(fabs(c1.r - c2.r) - abs(c1.c - c2.c))) return 1;    //2つの円が内接する場合
    return 2;                                                    //2つの円が交わる場合
}

//円と直線の交点
pair<Point, Point> getCrossPoints(const Circle &c, const Line &l) {
    assert(intersectLP(c,l));
    Vector pr = project(l, c.c);
    Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
    DD base = sqrt(c.r * c.r - norm(pr - c.c));
    return make_pair(pr + e * base, pr - e * base);
}

//円と円の交点
pair<Point, Point> getCrossPoints(const Circle &c1, const Circle &c2) {
    assert(intersect(c1, c2));
    DD d = abs(c1.c - c2.c);
    DD a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (c1.r * d * 2));
    DD t = arg(c2.c - c1.c);
    return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a));
}

//点pを通る円の接線
pair<Line, Line> tangent(const Circle &c, const Point &p) {
    assert(sgn(abs(c.c - p) - c.r) >= 0);
    if (!sgn(abs(c.c - p) - c.r)) {
        Point q = rot90(c.c - p);
        return pair<Line, Line>(Line(p,p+q), Line(p,p+q));
    } 
    Circle c2=Circle(p,sqrt(norm(c.c-p)-c.r*c.r));
    auto q = getCrossPoints(c,c2);
    return pair<Line, Line>(Line(p,q.first), Line(p,q.second));
}

//多角形の面積
DD area(const Polygon &g) {
    const int N = g.size();
    DD ret = 0;
    for (int i = 0; i < N; ++i) {
        ret += cross(g[i],g[(i+1)%N]);
    }
    return fabs(ret)/2;
}

//凸性判定
bool isConvex(const Polygon &g) {
    const int N = g.size();
    for (int i = 0; i < N; ++i) {
        if (ccw(g[i],g[(i+1)%N],g[(i+2)%N]) == -1) return 0;
    }
    return 1;
}

// 多角形-点の包含判定
int containment(const Polygon &g, const Point &p) {
    const int N = g.size();
    DD ang = 0;
    for (int i = 0; i < N; i++) {
        if (!ccw(g[i],g[(i+1)%N],p)) return 1; // pがgの辺上に存在する
        ang += atan2(cross(g[(i+1)%N] - p, g[i] - p), dot(g[(i+1)%N] - p, g[i] - p));
    }
    if (sgn(ang)) return 2; // pがgに含まれる
    return 0; // pがgに含まれない
}

//凸包
Polygon andrewScan(Polygon s) {
    Polygon u,l;
    const int N = s.size();
    if (N < 3) return s;
    sort(s.begin(), s.end(), ysort);
    u.emplace_back(s[0]);
    u.emplace_back(s[1]);
    l.emplace_back(s[N-1]);
    l.emplace_back(s[N-2]);
    
    for (int i = 2; i < s.size(); ++i) {
        // 凸包上の点も含めるなら ccw() == 1 含めないなら ccw() != -1
        for (int n = u.size(); n >= 2 && ccw(u[n-2],u[n-1],s[i]) == 1; --n) {
            u.pop_back();
        }
        u.emplace_back(s[i]);
    }

    for (int i = N - 3; i >= 0; --i) {
        // 凸包上の点も含めるなら ccw() == 1 含めないなら ccw() != -1
        for (int n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == 1; --n) {
            l.pop_back();
        }
        l.emplace_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (int i = u.size() - 2; i >= 1; --i) l.emplace_back(u[i]);

    return l;
}

//最遠点対
DD farthestpointpair(const Polygon &g) {
    const int N = g.size();
    if (N == 2) return abs(g[1] - g[0]);
    int i = 0, j = 0;
    for (int k = 0; k < N; ++k) {
        if (g[k].y > g[i].y) i = k;
        if (g[k].y < g[j].y) j = k;
    }

    DD ret = 0;
    int si = i, sj = j;
    while (i != sj || j != si) {
        ret = max(ret, abs(g[i]-g[j]));
        if (cross(g[(i+1)%N] - g[i], g[(j+1)%N] - g[j]) < -EPS) {
            i = (i+1)%N;
        } else {
            j = (j+1)%N;
        }
    }

    return ret;
}

/////////////////////////////////////////////////////////////////////////////////////////////

void CGL_1_A() {
    Point p1,p2; cin >> p1 >> p2;
    Line l(p1,p2);
    int Q; cin >> Q;
    while (Q--) {
        Point p; cin >> p;
        cout << project(l,p) << ln;
    }
}

void CGL_1_B() {
    Point p1,p2; cin >> p1 >> p2;
    Line l(p1,p2);
    int Q; cin >> Q;
    while (Q--) {
        Point p; cin >> p;
        cout << reflect(l,p) << ln;
    }
}

void CGL_1_C() {
    Point p0,p1; cin >> p0 >> p1;
    int Q; cin >> Q;
    while (Q--) {
        Point p2; cin >> p2;
        int v = ccw(p0,p1,p2);
        string ans;
        if (v==1) ans = "COUNTER_CLOCKWISE";
        if (v==-1) ans = "CLOCKWISE";
        if (v==2) ans = "ONLINE_BACK";
        if (v==-2) ans = "ONLINE_FRONT";
        if (v==0) ans = "ON_SEGMENT";
        cout << ans << ln;
    }
}

void CGL_2_A() {
    int Q; cin >> Q;
    while (Q--) {
        Point p0,p1,p2,p3; cin >> p0 >> p1 >> p2 >> p3;
        if (isParallel(p0,p1,p2,p3)) cout << 2 << ln;
        else if (isOrthogonal(p0,p1,p2,p3)) cout << 1 << ln;
        else cout << 0 << ln;
    }
}

void CGL_2_B() {
    int Q; cin >> Q;
    while (Q--) {
        Point p0,p1,p2,p3; cin >> p0 >> p1 >> p2 >> p3;
        cout << intersectSP(p0,p1,p2,p3) << ln;
    }
}

void CGL_2_C() {
    int Q; cin >> Q;
    while (Q--) {
        Point p0,p1,p2,p3; cin >> p0 >> p1 >> p2 >> p3;
        Segment s0(p0,p1), s1(p2,p3);
        cout << getCrossPointSP(s0,s1) << ln;
    }
}

void CGL_2_D() {
    int Q; cin >> Q;
    while (Q--) {
        Point p0,p1,p2,p3; cin >> p0 >> p1 >> p2 >> p3;
        Segment s0(p0,p1), s1(p2,p3);
        cout << getDistanceSP(s0,s1) << ln;
    }
}

void CGL_3_A() {
    int N; cin >> N;
    Polygon P(N);
    rep(i,N) cin >> P[i];

    cout << fixed << setprecision(1) << area(P) << ln;
}

void CGL_3_B() {
    int N; cin >> N;
    Polygon P(N);
    rep(i,N) cin >> P[i];

    cout << isConvex(P) << ln;
}

void CGL_3_C() {
    int N; cin >> N;
    Polygon P(N);
    rep(i,N) cin >> P[i];

    int Q; cin >> Q;
    while (Q--) {
        Point p; cin>> p;
        cout << containment(P,p) << ln;
    }
}

void CGL_4_A() {
    int N; cin >> N;
    Polygon P(N);
    rep(i,N) cin >> P[i];

    auto ans = andrewScan(P);
    cout << ans.size() << ln;
    for (const auto &i : ans) {
        cout << (int)round(i.x) << " " << (int)round(i.y) << ln;
    }
}

void CGL_7_A() {
    Circle c1,c2; cin >> c1 >> c2;
    cout << intersect(c1,c2) << ln;
}

void CGL_7_F() {
    Point p; cin >> p;
    Circle c; cin >> c;
    auto ans = tangent(c,p);
    Polygon P = {ans.first.p2, ans.second.p2};
    sort(all(P));
    cout << P[0] << ln;
    cout << P[1] << ln;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cout << fixed << setprecision(20);
    //CGL_1_A();
    //CGL_1_B();
    //CGL_1_C();
    //CGL_2_A();
    //CGL_2_B();
    //CGL_2_C();
    //CGL_2_D();
    //CGL_3_A();
    //CGL_3_B();
    //CGL_3_C();
    CGL_4_A();
    //CGL_7_A();
    //CGL_7_F();
}

/*
  verified on 2020/06/03
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_C&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_B&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_C&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_A&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_A&lang=ja
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_F&lang=ja
*/


Measured memory_bytes: 8060