#include <iostream>
#include <vector>
using namespace std;
typedef pair<int,int> pii;

const int MAXW = 2e3+2+3;
const int MAXH = 2e3+2+3;

int H,W;
char grid[MAXH][MAXW];
bool block[MAXH][MAXW];
int r[MAXH][MAXW];
vector<pii> rects;

int main()
{
        cin >> H >> W;
        for (int i=0; i<H; i++)
                for (int j=0; j<W; j++)
                        cin >> grid[i][j];

        for (int i=0; i<H-1; i++) {
                for (int j=0; j<W-1; j++) {
                        int ct=0;
                        if (grid[i][j] == '#')
                                ct++;
                        if (grid[i+1][j] == '#')
                                ct++;
                        if (grid[i][j+1] == '#')
                                ct++;
                        if (grid[i+1][j+1] == '#')
                                ct++;
                        if (ct == 1 || ct == 3)
                                block[i][j] = true;
                }
        }

        for (int i=0; i<H-1; i++)
                r[i][W-1] = 0;
        for (int j=0; j<W-1; j++)
                r[H-1][j] = 0;
        for (int j=W-2; j>=0; j--) {
                for (int i=0; i<H-1; i++) {
                        if (!block[i][j])
                                r[i][j] = r[i][j+1]+1;
                        else
                                r[i][j] = 0;
                }
        }

        /*for (int i=0; i<H-1; i++) {
                for (int j=0; j<W-1; j++) {
                        if (block[i][j])
                                cout << 'X';
                        else
                                cout << '.';
                }
                cout << "\n";
        }

        for (int i=0; i<H-1; i++) {
                for (int j=0; j<W-1; j++) {
                        cout << r[i][j] << " ";
                }
                cout << "\n";
        }
        cout << "\n";*/

        int max_ar=max(W,H);
        for (int j=W-2; j>=0; j--) {
                rects.clear();
                int width=0;
                for (int i=0; i<H; i++) {
                        if (r[i][j] > width) {
                                rects.push_back(pii(i,width));
                                width = r[i][j];
                        } else if (r[i][j] < width) {
                                pii p;
                                while (rects.size() > 0 && r[i][j] < width) {
                                        p = rects.back();
                                        rects.pop_back();
                                        if ((width+1)*(i-p.first+1) > max_ar) {
                                                max_ar = (width+1)*(i-p.first+1);
                                                //cout << p.first << " " << j << " " << width << " " << i-p.first << "\n";
                                        }
                                        width = p.second;
                                }

                                width = r[i][j];
                                if (width != 0) {
                                        rects.push_back(pii(p.first,p.second));
                                }
                        }
                }
        }

        cout << max_ar << "\n";
}

Measured memory_bytes: 23808