#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define allr(x)           (x).rbegin(),(x).rend()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi                vector<int>
#define vii               vector<pii>
#define mi                map<int,int>
#define mii               map<pii,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define el                '\n' 
 
 
void solve()
{   
    int n;
    cin>>n;
    vii v1,v2;
    rep(i,0,n){
      int x,y;
      cin>>x>>y;
      v1.pb({x,i});
      v2.pb({y,i});
    }
    sort(all(v1));
    sort(all(v2)); 

    

    
     int ans1=v1[n-1].fr-v1[0].fr;
     int ans2=v2[n-1].fr-v2[0].fr;
     int a,b;

     if(ans1>ans2){
      int ans=0;
         a=v1[n-1].sc;
         b=v1[0].sc;

         ans=max(ans,v1[n-1].fr-v1[1].fr);
         ans=max(ans,v1[n-2].fr-v1[0].fr);

         if((v2[n-1].sc==a&&v2[0].sc==b)||(v2[0].sc==a&&v2[n-1].sc==b)){
              ans=max(ans,v2[n-1].fr-v2[1].fr);
              ans=max(ans,v2[n-2].fr-v2[0].fr);
         }
         else{
          ans=max(ans,v2[n-1].fr-v2[0].fr);
         }
         cout<<ans<<el;
     }
     else if(ans2>ans1){
      vii vx=v1;
      v1=v2;
      v2=vx;
       int ans=0;
         a=v1[n-1].sc;
         b=v1[0].sc;

         ans=max(ans,v1[n-1].fr-v1[1].fr);
         ans=max(ans,v1[n-2].fr-v1[0].fr);

         if((v2[n-1].sc==a&&v2[0].sc==b)||(v2[0].sc==a&&v2[n-1].sc==b)){
              ans=max(ans,v2[n-1].fr-v2[1].fr);
              ans=max(ans,v2[n-2].fr-v2[0].fr);
         }
         else{
          ans=max(ans,v2[n-1].fr-v2[0].fr);
         }
         cout<<ans<<el;

     }
     else{
       int ans=0;
         a=v1[n-1].sc;
         b=v1[0].sc;

          if((v2[n-1].sc==a&&v2[0].sc==b)||(v2[0].sc==a&&v2[n-1].sc==b)){
              ans=max(ans,v1[n-1].fr-v1[1].fr);
              ans=max(ans,v1[n-2].fr-v1[0].fr);
               ans=max(ans,v2[n-1].fr-v2[1].fr);
              ans=max(ans,v2[n-2].fr-v2[0].fr);
              cout<<ans<<el;
         }
         else{
            cout<<ans1<<el;
         }
         
     }
}


signed main()
{   
    
     ios_base::sync_with_stdio(false);
     cin.tie(0); cout.tie(0);
 
   int t=1;
  // cin>>t;

   while(t--) solve();
   return 0;
}

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,m,mask[N],sz=0;
string s[N];
int main(){
	ll i,j;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
		for(j=0;j<m;j++)
		{
			if(s[i][j]=='1')
			{
				mask[i]|=(1<<j);
			}
		}
	}
	for(i=1;i<n;i++)
	{
		if(__builtin_popcount(mask[0]^mask[i])%2==1)
		{
			sz++;
		}
	}
	cout<<sz+sz*(n-1-sz)<<endl;
	return 0;
}