#include <iostream>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <deque>

int64_t cross(std::tuple<int64_t, int64_t> p0, std::tuple<int64_t, int64_t> p1, std::tuple<int64_t, int64_t> p2) {
    auto vx1 = std::get<0>(p1) - std::get<0>(p0);
    auto vy1 = std::get<1>(p1) - std::get<1>(p0);

    auto vx2 = std::get<0>(p2) - std::get<0>(p0);
    auto vy2 = std::get<1>(p2) - std::get<1>(p0);

    return vx1 * vy2 - vx2 * vy1;
}

int main(){
    int64_t n;
    std::cin >> n;

    std::vector< std::tuple<int64_t, int64_t> > vs(n);
    for (auto i = 0; i < n; ++i) {
        std::cin >> std::get<0>(vs[i]) >> std::get<1>(vs[i]);
    }
    std::sort(vs.begin(), vs.end(), [](std::tuple<int64_t, int64_t>lhs, std::tuple<int64_t, int64_t>rhs) {
        return (std::get<1>(lhs) < std::get<1>(rhs))
            || ((std::get<1>(lhs) == std::get<1>(rhs)) && (std::get<0>(lhs) < std::get<0>(rhs)) );
    });

    std::deque< std::tuple<int64_t, int64_t> > rights {vs[0], vs[1]};
    for (auto itr = std::next(std::next(vs.begin())); itr != vs.end(); ++itr) {
        while(rights.size() >= 2 && cross(*std::next(rights.rbegin()), *rights.rbegin(), *itr) < 0) {
            rights.pop_back();
        }
        rights.push_back(*itr);
    }
    std::deque< std::tuple<int64_t, int64_t> > lefts {*std::rbegin(vs), *std::next(vs.rbegin())};
    for (auto itr = std::next(std::next(vs.rbegin())); itr != vs.rend(); ++itr) {
        while(lefts.size() >= 2 && cross(*std::next(lefts.rbegin()), *lefts.rbegin(), *itr) < 0) {
            lefts.pop_back();
        }
        lefts.push_back(*itr);
    }
    rights.pop_back();
    lefts.pop_back();
    
    std::cout << rights.size() + lefts.size() << std::endl;

    for (auto itr = rights.begin(); itr != rights.end(); ++itr) {
        std::cout << std::get<0>(*itr) << ' ' << std::get<1>(*itr) << std::endl;
    }
    for (auto itr = lefts.begin(); itr != lefts.end(); ++itr) {
        std::cout << std::get<0>(*itr) << ' ' << std::get<1>(*itr) << std::endl;
    }

    return 0;
}
