Problem:
Score : 700 points

Problem Statement

We have a board with an H \times W grid.
Each square in the grid is painted in black or white. The square at the i-th row from the top and j-th column from the left is black if the j-th character in S_i is #, and white if that character is ..

Snuke can perform the following operation on the grid any number of times:

Select a row or column in the grid, and invert the color of all the squares in that row or column (that is, black squares become white and vice versa).

Then, Snuke draws a rectangle along grid lines. Here, all the squares contained in the rectangle must be painted in black.

Find the maximum possible area of Snuke's rectangle when the operation is performed optimally.

Constraints

2 \leq H \leq 2000

2 \leq W \leq 2000

|S_i| = W

S_i consists of # and ..

Input

Input is given from Standard Input in the following format:

H W
S_1
S_2
:
S_H

Output

Print the maximum possible area of Snuke's rectangle.

Sample Input 1

3 3
..#
##.
.#.

Sample Output 1

6

If the first row from the top and the third column from the left are inverted, a 2 \times 3 rectangle can be drawn, as shown below:

Sample Input 2

4 4
....
....
....
....

Sample Output 2

16

Sample Input 3

10 8
##...#.#
##...#.#
..###.#.
#.##.#.#
.#..#.#.
..##.#.#
##.#.#..
...#.#..
###.#.##
###..###

Sample Output 3

27

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

//2018年  3月 27日 火曜日 00:08:28 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
string str[2010];
bool used[2010][2010];
int B[2010][2010];

int find_rect(int D[2010]) {
	stack<int> S;
	int res = 0;
	rep(i, 0, M) {
		while(!S.empty()) {
			int at = S.top();
			if(D[at] >= D[i]) S.pop();
			else break;
		}
		int at = S.empty() ? -1 : S.top();
		// debug(i, i - at + 1, at, S.empty());
		MAX(res, (i - at + 1) * (D[i] + 1));
		S.push(i);
	}
	return res;
}

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		cin >> str[i];
	}
	rep(i, 0, N - 1) {
		rep(j, 0, M - 1) {
			int tmp = 0;
			rep(k, 0, 2) {
				rep(l, 0, 2) {
					if(str[i + k][j + l] == '#') {
						tmp++;
					}
				}
			}
			if(tmp % 2) used[i][j] = 1;
		}
	}
	int ans = max(N, M);
	N--; M--;
	rep(j, 0, M) {
		if(used[0][j]) B[0][j] = 0;
		else B[0][j] = 1;
	}
	rep(i, 1, N) {
		rep(j, 0, M) {
			if(used[i][j]) B[i][j] = 0;
			else B[i][j] = B[i - 1][j] + 1;
		}
	}
	// rep(i, 0, N) {
	// 	debug(vi(B[i], B[i] + M));
	// }
	rep(i, 0, N) {
		MAX(ans, find_rect(B[i]));
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}