#include<iostream>
#include<cstdio>
#include<complex>
#include<cmath>
#include<algorithm>
#include<utility>
#include<stack>
using namespace std;

pair<int,int> P[100000];
int ANS[100000];
int numa=0;

int main(){
  int n;
  cin >> n;

  int x,y;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    P[i]=make_pair(y,x);
  }

  sort(P,P+n);
  ANS[0]=0;
  ANS[1]=1;
  numa=2;

  int s,e,t,x1,x2,y1,y2;
  for(int i=2;i<n;i++){
    s=numa;
    e=0;
    while(s-e>1){
      t=(s+e)/2;
      y1=P[ANS[t-1]].first-P[ANS[t]].first;
      x1=P[ANS[t-1]].second-P[ANS[t]].second;
      y2=P[i].first-P[ANS[t]].first;
      x2=P[i].second-P[ANS[t]].second;
      if(x1*y2-x2*y1<=0)e=t;
      else s=t;
    }
    numa=s+1;
    ANS[s]=i;
  }
  /*
 for(int i=0;i<numa;i++){
    cout << P[ANS[i]].second <<
      " " << P[ANS[i]].first << endl;
  }
  */
  ANS[s+1]=n-2;
  numa++;
  int half=s;
  for(int i=n-3;i>=0;i--){
    s=numa;
    e=half;
    while(s-e>1){
      t=(s+e)/2;
      y1=P[ANS[t-1]].first-P[ANS[t]].first;
      x1=P[ANS[t-1]].second-P[ANS[t]].second;
      y2=P[i].first-P[ANS[t]].first;
      x2=P[i].second-P[ANS[t]].second;
      if(x1*y2-x2*y1<=0)e=t;
      else s=t;
    }
    numa=s+1;
    ANS[s]=i;
  }
  
  cout << numa-1 << endl;
  for(int i=0;i<numa-1;i++){
    cout << P[ANS[i]].second <<
      " " << P[ANS[i]].first << endl;
  }
}



  