#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;

long Inf = 1000000000000;

double grad(pair<double, double> &l, pair<double, double> &r){
    if(l.first == r.first){
        return Inf;
    }else{
        return (l.second - r.second) / (l.first - r.first);
    }
}

int main(){
    int n;
    cin >> n;
    vector<pair<double, double> > p;
    vector<pair<double, double> > ans;
    vector<pair<double, double> > ans_;
    double x, y;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        p.push_back(make_pair(x, y));
    }
    sort(p.begin(), p.end());
    ans.push_back(p[0]);
    ans.push_back(p[1]);
    double g, g_;
    g = grad(p[0], p[1]);
    pair<double, double> last = p[1]; 
    for(int i = 2; i < n; i++){
        //cout << i << " " << p[i].first << " " << p[i].second << endl;
        g_ = grad(last, p[i]);
        //cout << g << endl;
        //cout << g_ << endl;
        if (g_ > g){
            g = g_;
            ans.push_back(p[i]);
            last = p[i];
        }else if(g_ == g){
            ans.push_back(p[i]);
            last = p[i];
        }else{
            while(g_ < g && ans.size() > 1){
                ans.pop_back();
                pair<double, double> a = ans[ans.size()-1];
                pair<double, double> b = ans[ans.size()-2];
                g = grad(b,a);
                g_ = grad(a, p[i]);
                /*cout << "a: " << a.first << " " << a.second << endl;
                cout << "b: " << b.first << " " << b.second << endl;
                cout << "p[i]: " << p[i].first << " " << p[i].second << endl;
                cout << "g: " << g << endl;
                cout << "g_: " << g_ << endl;*/
            }
            g = g_;
            ans.push_back(p[i]);
            last = p[i];

        }
    }

    reverse(p.begin(), p.end());
    ans_.push_back(p[0]);
    ans_.push_back(p[1]);
    g = grad(p[0], p[1]);
    last = p[1]; 
    for(int i = 2; i < n; i++){
        //cout << i << " " << p[i].first << " " << p[i].second << endl;
        g_ = grad(last, p[i]);
        //cout << g << endl;
        //cout << g_ << endl;
        if (g_ > g){
            g = g_;
            ans_.push_back(p[i]);
            last = p[i];
        }else if(g_ == g){
            ans_.push_back(p[i]);
            last = p[i];
        }else{
            while(g_ < g && ans_.size() > 1){
                ans_.pop_back();
                pair<double, double> a = ans_[ans_.size()-1];
                pair<double, double> b = ans_[ans_.size()-2];
                //cout << "a: " << a.first << " " << a.second << endl;
                //cout << "b: " << b.first << " " << b.second << endl;
                //cout << "p[i]: " << p[i].first << " " << p[i].second << endl;
                g = grad(b,a);
                g_ = grad(a, p[i]);
                //cout << "g: " << g << endl;
                //cout << "g_: " << g_ << endl;
            }
            g = g_;
            ans_.push_back(p[i]);
            last = p[i];
        }
    }
    cout << ans.size()+ans_.size() - 2 << endl;
    /*for(int i = 0; i < ans.size(); i++){
        //cout << ans[i].first << " " << ans[i].second << endl;
        push_back(ans[i]);
    }*/
    for(int i = 1; i < ans_.size()-1; i++){
        //cout << ans_[i].first << " " << ans_[i].second << endl;
        ans.push_back(ans_[i]);
    }
    int i = 0;
    while(ans[i].second > ans[i+1].second){
        ans.push_back(ans[i]);
        i++;
    }
    //cout << i << endl;
    for(int j = i; j < ans.size(); j++){
        cout << ans[j].first << " " << ans[j].second << endl;
    }
}

Measured memory_bytes: 8120