#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;
	char k;
	bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
pair<int,int>a[200005];
int s;
set<int,int>se;
int dis(int x,int y){return max(abs(a[x].first-a[y].first),abs(a[x].second-a[y].second));}
set<pair<int,pair<int,int> > >q2;
set<pair<int,int> >q,q1;
int main(){
	s=read;
	for(int i=1;i<=s;++i)a[i]=make_pair(read,read);
	sort(a+1,a+s+1);
	q.insert(make_pair(a[1].second,1));
	q.insert(make_pair(a[2].second,2));
	q1.insert(make_pair(-a[1].second,1));
	q1.insert(make_pair(-a[2].second,2));
	q2.insert(make_pair(dis(1,2),make_pair(1,2)));
	for(int i=3;i<=s;++i){
		q2.insert(make_pair(dis(1,i),make_pair(1,i)));
		q2.insert(make_pair(dis(2,i),make_pair(2,i)));
		auto j=q.begin();
		q2.insert(make_pair(dis(j->second,i),make_pair(j->second,i)));++j;
		q2.insert(make_pair(dis(j->second,i),make_pair(j->second,i)));j=q1.begin();
		q2.insert(make_pair(dis(j->second,i),make_pair(j->second,i)));++j;
		q2.insert(make_pair(dis(j->second,i),make_pair(j->second,i)));
		q.insert(make_pair(a[i].second,i));
		q1.insert(make_pair(-a[i].second,i));
		q.erase(q.begin());q1.erase(q1.begin()); 
	}auto i=q2.end();--i;--i;
	cout<<i->first;
	return 0;
}

#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs           v.size()
#define ss           s.size()
#define sz(a)       a.size()
#define sot(v)       sort(v.begin(),v.end())
#define all(v)       (v).begin(), (v).end()
#define rev(v)       reverse(v.begin(),v.end())
#define revsot(v)    sort(v.rbegin(),v.rend())
#define yes          cout<<"YES"<<endl
#define no           cout<<"NO"<<endl
#define ii           pair<int, int>
#define int          long long
#define ll           long long
#define ull          unsigned long long
#define pb           push_back
#define mpp          make_pair
#define Okay         0
#define pi           3.14159

const int mx = 2e6+100;
const int inf = 1e18;
const int mod = 1e9+7;
using namespace std;

void solve(){
    int n;
    cin>>n;
    int res = n/100;
    res++;
    cout<<res*100 - n <<endl;
}

int32_t main(){
    Fast;
//    int tst;
//    cin>>tst;
//    while(tst--)
    solve();
    return Okay;
}
