#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
inline double distance(double y1, double x1, double y2, double x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, 1, 0, -1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

long long max_rectangle_in_histogram(const vector<int> &height) {
    const unsigned int N = height.size();

    // L
    vector<int> L(N);
    {
        int t = 0; // スタックのサイズ
        int st[N];
        for (int i = 0; i < N; ++i) {
            while (t > 0 and height[st[t - 1]] >= height[i]) {
                t--;
            }
            L[i] = (t == 0 ? 0 : (st[t - 1] + 1));
            st[t++] = i;
        }
    }

    // R
    vector<int> R(N);
    {
        int t = 0;
        int st[N];
        for (int i = N - 1; i >= 0; i--) {
            while (t > 0 and height[st[t - 1]] >= height[i]) {
                t--;
            }
            R[i] = (t == 0 ? N : st[t - 1]);
            st[t++] = i;
        }
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {
//        ans = max(ans, (long long)height[i] * (R[i] - L[i]));
        ans = max(ans, (long long)(1 + height[i]) * (1 + (R[i] - L[i])));
    }

    return ans;
}

long long max_rectangle(const vector<vector<int>> &field) {
    const int space = 1;    // 塗れるマス

    const unsigned int H = field.size();
    const unsigned int W = field[0].size();

    long long ans = 0;
    vector<int> line(W, 0); // ある行について上にいくつスペースがあるか
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if (field[y][x] != space) {
                line[x] = 0;
            }
            else {
                line[x]++;
            }
        }
        ans = max(ans, max_rectangle_in_histogram(line));
    }
    return ans;
}


int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<int>> field(H, vector<int>(W));
    FOR(y, 0, H) {
        string s;
        cin >> s;
        FOR(x, 0, W) {
            field[y][x] = (s[x] == '.');
        }
    }

    vector<vector<int>> memo(H - 1, vector<int>(W - 1, 1));
    FOR(y, 0, H - 1) {
        FOR(x, 0, W - 1) {
            if ((field[y][x] + field[y + 1][x] + field[y][x + 1] + field[y + 1][x + 1]) % 2 != 0) {
                memo[y][x] = 0;
            }
        }
    }
    LL ans = max(H, W);
    ans = max(ans, max_rectangle(memo));
    print(ans);

    return 0;
}

Measured memory_bytes: 31616