#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define ALL(a) (a).begin(),(a).end()
#define ALL2(a, n) (a),(a)+(n)
template<class T,class C> T max(T a,C b){ return std::max(a, (T)b); }
template<class T,class C> T min(T a,C b){ return std::min(a, (T)b); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  string s="110",t;
  
  cin >> n;
  cin >> t;
  m = modpow(10,10,0);
  k = 0;
  if(t=="1"){//コーナーケース
    cout << 2*m << endl;
    return 0;
  }
  for(i=0;i<n;i++){
    if(i+2<=n){
      if(t.substr(i,2)=="00"){//ダメ
        cout << 0 << endl;
        return 0;
      }
    }
    if(i+3<=n){
      if(t.substr(i,3)=="111"){//ダメ2
        cout << 0 << endl;
        return 0;
      }
      if(t.substr(i,3)=="010"){//ダメ3
        cout << 0 << endl;
        return 0;
      }
    }
  }
  for(i=0;i<n;i++){
    if(t[i]=='0') k++;
  }
  if(t[n-1] == '1') k++;
  result = m-k+1;
  
  cout << result << endl;
  return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define rng(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i)
#define per(i, b) gnr(i, 0, b)
#define all(obj) begin(obj), end(obj)
#define allr(obj) rbegin(obj), rend(obj)
#define cinv(a) rep(i, (int)a.size()) cin >> a[i]
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<Pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};
const int MOD =	1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const long double eps = 1e-10;
const char nl = '\n';

ll power(ll a, ll b) { return b ? power(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD : 1; }

ll nCk(int n, int k)
{
	ll x = 1, y = 1;
	for (int i = 1; i <= k; ++i)
	{
		x = x * (n - i + 1) % MOD;
		y = y * i % MOD;
	}
	return x * power(y, MOD - 2) % MOD;
}

struct UF
{
	vi d;
	UF(int n) : d(n, -1) {}
	int root(int x)
	{
		if (d[x] < 0)
			return x;
		return d[x] = root(d[x]);
	}
	bool unite(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -d[root(x)]; }
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(20);	
	int n; cin >> n;	
	vi x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	int x_min1 = INF, x_min2 = INF, y_min1 = INF, y_min2 = INF;
	int x_max1 = 0, x_max2 = 0, y_max1 = 0, y_max2 = 0;
	int index_x_max1, index_x_min1, index_y_max1, index_y_min1;

	auto two_max = [&](int &max1, int &max2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (max1 < vec[i])
			{
				max2 = max1;
				max1 = vec[i];
				index = i;
			}
			else if (max2 < vec[i])
			{
				max2 = vec[i];
			}
		}
	};
	two_max(x_max1, x_max2, index_x_max1, x);
	two_max(y_max1, y_max2, index_y_max1, y);

	auto two_min = [&](int &min1, int &min2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (min1 > vec[i])
			{
				min2 = min1;
				min1 = vec[i];
				index = i;
			}
			else if (min2 > vec[i])
			{
				min2 = vec[i];
			}
		}
	};
	two_min(x_min1, x_min2, index_x_min1, x);
	two_min(y_min1, y_min2, index_y_min1, y);

	if (index_x_max1 == index_y_max1 && index_x_min1 == index_y_min1)
		cout << max(max(x_max1 - x_min2, x_max2 - x_min1), max(y_max1 - y_min2, y_max2 - y_min1)) << nl;
	else
	{
		vi ans;
		ans.pb(x_max1 - x_min1);
		ans.pb(y_max1 - y_min1);
		ans.pb(x_max1 - x_min2);
		ans.pb(y_max1 - y_min2);
		ans.pb(x_max2 - x_min1);
		ans.pb(y_max2 - y_min1);
		sort(allr(ans));
		cout << ans[1] << nl;
	}
}	
	
