#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

const int N = 2005;

int n, m;
string s[N];
int dp[N][N];
int cnt_col;
int l[N], r[N], col[N];
multiset<int> best;
vector<int> bad[N];

void cut(int p) {
    int c = col[p];
    int L = l[c];
    int R = r[c];
    best.erase(best.find(R - L + 1));
    best.insert(p - L);
    best.insert(R - p + 1);
    if (p - L < R - p + 1) {
        rep(i, L, p) col[i] = cnt_col;
        l[cnt_col] = L;
        r[cnt_col] = p - 1;
        l[c] = p;
        cnt_col++;
    } else {
        rep(i, p, R + 1) col[i] = cnt_col;
        l[cnt_col] = p;
        r[cnt_col] = R;
        r[c] = p - 1;
        cnt_col++;
    }
}

void run() {
    cin >> n >> m;
    rep(i, 0, n) cin >> s[i];
    int ans = 0;
    
    per(j, m - 1, 0) {
        rep(i, 1, n) {
            if (j == m - 1) {
                dp[i][j] = m;
                continue;
            }
            bool t1 = (s[i - 1][j] == s[i - 1][j + 1]);
            bool t2 = (s[i][j] == s[i][j + 1]);
            if (t1 == t2) {
                dp[i][j] = dp[i][j + 1];
            } else {
                dp[i][j] = j + 1;
            }
        }
    }
    
    rep(j, 0, m) {
        best.clear();
        best.insert(n);
        cnt_col = 1;
        l[0] = 0;
        r[0] = n - 1;
        rep(t, 0, m + 1) bad[t].clear();
        rep(i, 0, n) {
            col[i] = 0;
            bad[dp[i][j]].pb(i);
        }
        rep(r, j, m) {
            for (int i : bad[r]) {
                cut(i);
            }
            maxi(ans, (r - j + 1) * (*best.rbegin()));
        }
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 31616