#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

ll a[16][16];
ll v[1 << 16]; // value of that submask
ll dp[1 << 16];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	rep(i, 0, n) rep(j, 0, n) read(a[i][j]);

	for (int b = 0; b < (1 << n); b++) {
		for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if ((b >> i & 1) && (b >> j & 1))
			v[b] += a[i][j];
	}

	dp[0] = 0;
	for (int i = 1; i <= n; i++) for (int j = 0; j < (1 << n); j++) if (__builtin_popcount(j) == i) {
		dp[j] = v[j];
		for (int k = j; k > 0; k = (k - 1) & j) {
			chmax(dp[j], dp[j ^ k] + v[k]);
		}
	}

	write(dp[(1 << n) - 1]);
}

#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
const int maxn=2e3+5;
char S[maxn];
int s[maxn][maxn],a[maxn][maxn];
int i,j,H,W,ans,h[maxn][maxn],t,q[maxn][2],cnt,len;
int main(){
	scanf("%d%d",&H,&W);
	fo(i,1,H) {
		scanf("%s",S+1);
		fo(j,1,W) s[i][j]=S[j]=='#';
	}
	ans=max(H,W);
	if (H==1||W==1) return printf("%d\n",ans),0;
	H--,W--;
	fo(i,1,H){
		cnt=0;
		fo(j,1,W){
			t=s[i][j]^s[i][j+1]^s[i+1][j]^s[i+1][j+1]^1;
			len=h[i][j]=(t)?h[i-1][j]+1:0;
			for(;cnt&&q[cnt][0]>len;cnt--) ans=max(ans,(q[cnt][0]+1)*(j-q[cnt-1][1]));
			q[++cnt][0]=len,q[cnt][1]=j;
		}
		for(;cnt;cnt--) ans=max(ans,(q[cnt][0]+1)*(W-q[cnt-1][1]+1));
	}
	printf("%d\n",ans);
}