#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

#define endl codeforces

#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
using size_type = ssize_t;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T, std::size_t Head, std::size_t... Tail> 
struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };

template <typename T, std::size_t Head> 
struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };

template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { 
    if constexpr (std::is_invocable<F, Args...>::value) { 
        t = f(args...); 
    } else { 
        for (size_type i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); 
    } 
}
#endif

template <typename T> vec<T> make_v(size_type sz) { return vec<T>(sz); }

template <typename T, typename... Tail> 
auto make_v(size_type hs, Tail&&... ts) { 
    auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); 
    return vec<decltype(v)>(hs, v); 
}

namespace init__ { 
struct InitIO { 
    InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } 
} init_io; 
}


namespace geo {

using value_type = long double;
using Point = std::complex<value_type>;

const value_type eps = 1e-12;
const value_type pi = 3.14159265358979323846264338327950288419716939937510L;

const value_type err_v = std::numeric_limits<value_type>::max();
const Point err_p(err_v, err_v);

struct DualPoints : public std::pair<Point, Point> {
    using std::pair<Point, Point>::pair;

    Point& operator [](size_t idx) { return idx == 0 ? first : second; }
    
    const Point& operator [](size_t idx) const { return idx == 0 ? first : second; }
};

struct get_xy {
    value_type &x, &y;

    get_xy(value_type &x, value_type &y) : x(x), y(y) { }

    get_xy& operator =(const Point &p) {
        x = std::real(p);
        y = std::imag(p);
        return *this;
    }
};

struct Circle {
    Point p;
    value_type r;

    Circle(Point p, value_type r) : p(p), r(r) { }
};

struct Line : public DualPoints {
    using DualPoints::DualPoints;
};

struct Seg : public DualPoints {
    using DualPoints::DualPoints;
};

value_type dot(const Point &a, const Point &b) {
    return std::real(std::conj(a) * b);
}

value_type cross(const Point &a, const Point &b) {
    return std::imag(std::conj(a) * b);
}

bool is_zero(value_type a) {
    return std::abs(a) <= eps;
}

bool eq(value_type a, value_type b) {
    return is_zero(a - b);
}

// projection from p to l
Point proj(const Line &l, const Point &p) {
    value_type mul = dot(p - l[0], l[1] - l[0]) / norm(l[0] - l[1]);  // cos(theta) / (p-l[0]).norm()
    return l[0] + mul * (l[1] - l[0]);
}

Point refl(const Line &l, const Point &p) {
    Point pr = proj(l, p);
    return p + ((pr - p) * static_cast<value_type>(2));
}

value_type fix_arg(value_type arg) {
    while (arg < 0) arg += 2 * pi;
    while (2 * pi <= arg) arg -= 2 * pi;
    return arg;
}

value_type fix_arg(const Point &a) {
    return fix_arg(std::arg(a));
}

auto to_pair(const Point &p) {
    value_type x, y;
    get_xy(x, y) = p;
    return std::make_pair(x, y);
}

bool comp_coclock(const Point &p1, const Point &p2) {
    auto fa = fix_arg(arg(p1));
    auto fb = fix_arg(arg(p2));
    if (eq(fa, fb)) return std::norm(p1) < std::norm(p2);
    return fa < fb;
}

bool comp_like_pair(const Point &p1, const Point &p2) {
    return to_pair(p1) < to_pair(p2);
}

Point rotate(const Point &p, value_type arg) {
    std::complex<value_type> r(std::cos(arg), std::sin(arg));
    return p * r;
}

value_type cos(value_type a, value_type b, value_type c) {
    return (a * a + b * b - c * c) / (2 * a * b);
}

bool is_parallel(const Line &l1, const Line &l2) {
    return is_zero(cross(l1[1] - l1[0], l2[1] - l2[0]));
}

bool is_same_line(Point o, Point a, Point b) {
    return is_zero(cross(a - o, b - o));
}

}

namespace geo {

/*      
 * Point c is
 *
 *         +1
 * ------------------
 *   +2  a    b  -2
 * ------------------
 *         -1
 */

int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)             return +1;
    if (cross(b, c) < 0)             return -1;
    if (dot(b, c) < 0)               return +2;
    if (std::norm(b) < std::norm(c)) return -2;
    return 0;
}

void ccw_sort(vec<Point> &v, Point o) {
    int lis[] = { -2, 1, 2, -1, };
    auto get_ccw_idx = [&](int c) {
        for (int i = 0; i < 4; i++) if (c == lis[i]) return i;
        return 4;
    };

    auto p = v[0];
    std::sort(v.begin() + 1, v.end(), 
              [&](Point a, Point b) {
                  if (a == b) return false;
                  int ca = ccw(o, p, a);
                  int cb = ccw(o, p, b);
                  if (ca != cb) return get_ccw_idx(ca) < get_ccw_idx(cb);
                  auto res = ccw(o, a, b);
                  if (std::abs(res) == 1) return res == 1;
                  return comp_like_pair(a, b);
              });
}

}

namespace geo {

vec<Point> build_convex_hull_incremental(vec<Point> pv) {
    std::sort(ALL(pv), comp_like_pair);
    auto minx = std::real(pv.front()),
         maxx = std::real(pv.back());

    {
        vec<Point> tmp;
        for (size_type i = 0; i < pv.size(); i++) {
            bool use = true;
            do {
                if (i == 0) break;
                if (i + 1 == pv.size()) break;
                auto pr = std::real(pv[i]);
                if (pr == minx) break;
                if (pr == maxx) break;
                if (pr != std::real(pv[i - 1])) break;
                if (pr != std::real(pv[i + 1])) break;
                use = false;
            } while (false);
            if (use) tmp.push_back(pv[i]);
        }
        size_type i = 0;
        while (i < tmp.size() && std::real(tmp[i]) == minx) i++;
        std::reverse(tmp.begin(), tmp.begin() + i);
        pv = std::move(tmp);
    }

    std::stack<Point, vec<Point>> ustk, lstk;
    size_type idx = 0;
    while (true) {
        auto p = pv[idx];
        bool f = (!ustk.empty() && std::real(p) != std::real(ustk.top()));
        ustk.push(pv[idx]);
        lstk.push(pv[idx]);
        idx++;
        if (f) break;
    }

    for (size_type i = idx; i < pv.size(); i++) {
        auto p = pv[i];
        while (2 <= ustk.size()) {
            auto p1 = ustk.top(); 
            ustk.pop();
            auto p2 = ustk.top();
            auto c = ccw(p, p1, p2);
            if (c == -1) continue;
            ustk.push(p1);
            break;
        }
        while (2 <= lstk.size()) {
            auto p1 = lstk.top();
            lstk.pop();
            auto p2 = lstk.top();
            auto c = ccw(p, p1, p2);
            if (c == 1) continue;
            lstk.push(p1);
            break;
        }
        ustk.push(p);
        lstk.push(p);
    }

    pv.clear();
    while (lstk.size()) {
        pv.push_back(lstk.top());
        lstk.pop();
    }
    std::reverse(ALL(pv));
    while (ustk.size()) {
        auto p = ustk.top();
        ustk.pop();
        if (std::real(p) == minx) continue;
        if (std::real(p) == maxx) continue;
        pv.push_back(p);
    }
    return pv;
}

}

int main() {
    ll n;
    std::cin >> n;
    vec<geo::Point> pv(n);
    for (auto &&e : pv) {
        ll x, y;
        std::cin >> x >> y;
        e = geo::Point(x, y);
    }

    auto res = geo::build_convex_hull_incremental(pv);
    auto to_swapped_pair = [&](const geo::Point &p) {
        geo::value_type x, y;
        geo::get_xy(x, y) = p;
        return std::make_pair(y, x);
    };
    ll idx = std::distance(res.begin(),
                           std::min_element(ALL(res), [&](const auto &p1, const auto &p2) {
                               return to_swapped_pair(p1) < to_swapped_pair(p2);
                           }));
    std::cout << res.size() << "\n";
    for (ll i = 0; i < res.size(); i++, idx++) {
        idx %= res.size();
        auto e = res[idx];
        ll x = std::real(res[idx]), y = std::imag(e);
        std::cout << x << ' ' << y << "\n";
    }
    return 0;
}



Measured memory_bytes: 12748