#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 2020;
typedef long long ll;
const int mod = 998244353;
 inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
 }
 inline ll inverse(int x){ return pow(x, mod - 2); }
int h, w;
char ch[maxn][maxn];
int right[maxn][maxn];
int down[maxn][maxn];
int can[maxn][maxn];

inline int calc(int * a) {
	auto min = [&](int x,int y){ return a[x] < a[y] ? x : y; };
	static int st[20][maxn];
	int ret = 0;
	for(int i = 1;i < h;++i) st[0][i] = i;
	for(int i = 1;i < 13;++i) for(int j = 1;j + (1 << i) - 1 < h;++j) {
		st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << i - 1)]);
	}
	std::function<void(int, int)> solve = [&](int l,int r) {
		if(l > r) return ;
		const int lg = std::__lg(r - l + 1);
		int mn = min(st[lg][l], st[lg][r - (1 << lg) + 1]);
		ret = std::max(ret, (a[mn] + 1) * (r - l + 2));
		solve(l, mn - 1), solve(mn + 1, r);
	};
	solve(1, h - 1);
	return ret;
}
int main() {
	  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> h >> w;
	rep(i, 1, h) cin >> ch[i] + 1;
	for(int i = h - 1;i >= 1;--i) {
		for(int j = w - 1;j >= 1;--j) {
			can[i][j] = !(ch[i][j] + ch[i + 1][j] + ch[i][j + 1] + ch[i + 1][j + 1] & 1);
			right[j][i] = can[i][j] ? right[j + 1][i] + 1 : 0;
		}
	}
	int ans = w;
	rep(i, 1, w - 1) ans = std::max(ans, calc(right[i]));
	cout << ans << '\n';
}

#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	int h,w; cin >> h >> w;
	vs s(h); rep(i,h) cin >> s[i];
	vl dist(h+1,-1);
	int ans = w;
	rep(j,w){
		vector<pii> st;
		st.emplace_back(0,0);
		REP(i,1,h+1){
			if(i < h){
				if(j==0 || dist[i] == 1){
					int d = 0;
					bool rev = s[i][j] != s[i-1][j];
					REP(k,j,w){
						if(rev == (s[i][k] != s[i-1][k])) d++;
						else break;
					}
					dist[i] = d;
				}else{
					dist[i]--;
				}
			}else{
				dist[i] = 0;
			}
			if(st.empty() || st.back().first < dist[i]){
				st.emplace_back(dist[i],i);
			}else{
				int pos = i;
				while(!st.empty()){
					if(st.back().first >= dist[i]){
						pii p = st.back();
						chmax(ans, p.first*(i-p.second)+p.first);
						pos = p.second;
						st.pop_back();
					}else{
						st.emplace_back(dist[i], pos);
						break;
					}
				}
			}
		}
	}
	cout << ans << "\n";
}