#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define db double
const db eps = 1e-10;

struct Point{
    db x, y;
    Point(db x=0, db y=0): x(x), y(y) {}    //必须有初始化
    bool operator < (const Point &p){
        return y < p.y || (y == p.y && x < p.x);
    }
};

typedef Point Vector;
Vector operator + (Vector a, Vector b){ return Point(a.x+b.x, a.y+b.y);}
Vector operator - (Point a, Point b){ return Vector(a.x-b.x, a.y-b.y);}
Vector operator * (Vector a, db k){ return Vector(a.x*k, a.y*k);}
Vector operator / (Vector a, db k){ return Vector(a.x/k, a.y/k);}

//inline将函数名为内联函数，不使用栈空间，直接运算，但不能有while,switch等复杂语句
inline db dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
}
inline db cross(Vector a, Vector b){
    return a.x*b.y - b.x*a.y;
}
db length(Vector a){
    return sqrt(dot(a, a));
}
db angle(Vector a, Vector b){
    return acos(dot(a, b) / length(a) / length(b));
}

int dcmp(db x){ //三态函数，eps间返回0，否则>eps返回1，反之-1
    if(fabs(x) < eps) return 0;
    return x < 0? -1: 1;
}
bool operator == (Point a, Point b){
    return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}

struct Segment{
    Point p1, p2;
    Segment(Point p1=Point(0, 0), Point p2 = Point(0, 0)): p1(p1), p2(p2) {};
};
typedef Segment Line;
typedef vector<Point> Polygon;
Point project(Line l, Point p){
    Vector a = l.p2 - l.p1, b = p - l.p1;
    db len_a = dot(a, a);   //这里不加sqrt，是因为下面算投影长度时，要除以两次len_a
    Vector tmp = a * (dot(a, b) / len_a);
    return l.p1+tmp;
}
Point reflect(Line l, Point p){
    Point tmp = project(l, p);
    return p + (tmp - p)*2;
}

int line_relation(Line l1, Line l2){
    Vector a = l1.p2 - l1.p1, b = l2.p2 - l2.p1;
    if(cross(a, b) == 0)
        return 1;
//        puts("parallel");
    else if(dot(a, b) == 0)
        return 0;
//        puts("orthogonal");
    else
        return -1;
//        puts("others");
}
int com_segment_relation(Point p0, Point p1, Point p2){
    Vector a = p1-p0, b = p2-p0;
    db flag = cross(p1-p0, p2-p0);
    if(flag < 0)  return 2;
    else if(flag > 0)  return 1;
    else{       //重合
        if(a.x*b.x < 0 || a.y*b.y < 0) return 3;
        else if(length(a) < length(b)) return 4;
        else return 5;
    }
}
bool segment_intersection(Segment s1, Segment s2){
    Point p1 = s1.p1, p2 = s1.p2, p3 = s2.p1, p4 = s2.p2;
    if(p2 < p1) swap(p1, p2);
    if(p4 < p3) swap(p3, p4);
    if(p2 < p3 || p4 < p1)
        return 0;       //同一直线上，最大最小排除
    else if(cross(p2-p1, p3-p1)*cross(p2-p1, p4-p1) > 0 || cross(p4-p3, p1-p3)*cross(p4-p3, p2-p3) > 0)
        return 0;
    else
        return 1;
}
Point segment_cross_point(Segment s1, Segment s2){
    if(!segment_intersection(s1, s2))
        exit(0);
    Vector a = s1.p2-s1.p1, b1 = s2.p1-s1.p1, b2 = s2.p2-s1.p1;
    db len = length(a);
    db h1 = fabs(cross(a, b1) / len);   //可以省去除len,求t时会消掉
    db h2 = fabs(cross(a, b2) / len);
    db t = h1 / (h1+h2);
    return s2.p1+(s2.p2-s2.p1)*t;
}
Point line_cross_point(Point P, Vector v, Point Q, Vector w){
    if(cross(v, w) == 0)
        exit(0);
    Vector u = P - Q;
    double t = cross(w, u) / cross(v, w);
    return P+v*t;
}
bool onsegment(Segment s, Point p){
    return dcmp(cross(s.p2-p, s.p1-p)) == 0 && dcmp(dot(s.p1-p, s.p2-p)) <= 0;  //顶点时，dot为0
}

inline db norm(db x){
    return x*x;
}
inline db dist_PtoP(Point p1, Point p2){
    return length(p2-p1);   //转换为向量模
}
db dist_PtoS(Segment s, Point p){
    if(s.p1 == s.p2) return length(p-s.p1);
    Vector v1 = s.p2 - s.p1, v2 = p - s.p1, v3 = p - s.p2;
    if(dcmp(dot(v1, v2) < 0))    return length(v2);
    else if(dcmp(dot(v1, v3) > 0))    return length(v3);
    else    return fabs(cross(v1, v2)) / length(v1);
}
inline db dist_PtoL(Line l, Point p){
    db tmp = cross(l.p2-l.p1, p-l.p1) / length(l.p2-l.p1);
    return fabs(tmp);
}
db dist_StoS(Segment s1, Segment s2){
    if(segment_intersection(s1, s2))
        return 0;
    db d1 = dist_PtoS(s2, s1.p1), d2 = dist_PtoS(s2, s1.p2), d3 = dist_PtoS(s1, s2.p1), d4 = dist_PtoS(s1, s2.p2);
    return min(min(d1, d2), min(d3, d4));
}
db dist_LtoL(Line l1, Line l2){
    if(line_relation(l1, l2) == 1)
        return dist_PtoL(l1, l2.p1);
    return 0;
}

db polygon_area(Polygon &pol){
    int sz = pol.size();
    db res = 0.0;
    for(int i=1; i<sz-1; ++i){  //分为n-1个三角形
        res += 0.5*cross(pol[i]-pol[0], pol[i+1]-pol[0]);
    }
    return fabs(res);
}

const int maxn = 1e5+5;
Point ch[maxn] = {0};
int convex_hull(Polygon &pol, int n){
    sort(pol.begin(), pol.end());
    int top = 0;
    for(int i=0; i<n; ++i){
        while(top > 1 && cross(ch[top-1] - ch[top-2], pol[i] - ch[top-1]) < 0) top --;
        ch[top ++] = pol[i];
    }
    int mid = top;
    for(int i=n-2; i>=0; --i){
        while(top > mid && cross(ch[top-1] - ch[top-2], pol[i] - ch[top-1]) < 0) top --;
        ch[top ++] = pol[i];
    }
//    printf("#%d\n", top);
    if(n > 1) top --;
    return top;
}
int point_in_polygon(Point p, Polygon &pol){
    int wn = 0; //winging number
    int n = pol.size();
    for(int i=0; i<n; ++i){
        if(onsegment(Segment(pol[i], pol[(i+1)%n]), p)) return 1;
        int k = dcmp(cross(pol[(i+1)%n]-pol[i], p-pol[i]));
        int d1 = dcmp(pol[i].y - p.y);
        int d2 = dcmp(pol[(i+1)%n].y - p.y);
        if(k > 0 && d1 <= 0 && d2 > 0) wn ++;
        if(k < 0 && d2 <= 0 && d1 > 0) wn --;
    }
    if(wn != 0) return 2;
    return 0;
}
int main()
{
    Point p1, p2, p3, p4;
    int n;
    cin >>n;
    Polygon pol;
    while(!pol.empty()) {pol.pop_back();}
    while(n --){
        cin >>p1.x >>p1.y;
        pol.push_back(p1);
    }
    n = pol.size();
    n = convex_hull(pol, n);
    cout <<n <<"\n";
    for(int i=0; i<n; ++i)
        cout << ch[i].x <<" "<< ch[i].y<<"\n";
    return 0;
}



Measured memory_bytes: 6540