#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

class UnionFind{
    using vec = vector<ll>;
    public:
        vec rank;
        vec parent;
        vec size;
        ll max_size;

        UnionFind(ll N){
            rank = vec(N, 0);
            parent = vec(N);
            size = vec(N, 1);
            max_size = 1;
            iota(parent.begin(), parent.end(), 0ll);
        }

        ~UnionFind(){
        }

        ll find(ll child){
            return (child == parent[child] ? child : parent[child] = find(parent[child]));
        }

        void unit(ll x, ll y){
            ll px = find(x);
            ll py = find(y);
            if(px == py){
                return;
            }
            if(rank[px] < rank[py]){
                swap(px, py);
            }
            parent[py] = px;
            size[px] += size[py];
            chmax(max_size, size[px]);
            rank[px] += (rank[px] == rank[py]);
        }

        ll get_max_size() { return max_size; }

        bool same(ll x, ll y){
            return (find(x) == find(y));
        }

};

const ll INF = 1e9;

int main() {
    init_io();
    ll H, W;
    cin >> H >> W;
    VV<ll> black(H), white(H);
    V<string> S(H);
    for(auto &s : S) cin >> s;
    VV<PLL> range(H), rrange(H);
    for(ll i = 0; i < H - 1; i++) {
        for(ll j = 0; j <= 1; j++) {
            auto check = [&](ll idx) { return (j == 0 ? S[i][idx] == S[i + 1][idx] : S[i][idx] != S[i + 1][idx]); };
            ll left = 0;
            while(1) {
                while(left < W && !check(left)) left++;
                if(left == W) break;
                ll right = left + 1;
                while(right < W && check(right)) right++;
                (j == 0 ? range : rrange)[i].emplace_back(right, left);
                if(right == W) break;
                left = right;
            }
            (j == 0 ? range : rrange)[i].emplace_back(INF, INF);
        }
    }
    ll ans = 0;
    for(ll i = 0; i < W; i++) {
        VV<PLL> to_merge(W + 2);
        for(ll j = 0; j < H - 1; j++) {
            auto ite1 = upper_bound(ALL(range[j]), PLL(i, -1));
            auto ite2 = upper_bound(ALL(rrange[j]), PLL(i, -1));
            PLL p1 = PLL(ite1->second, ite1->first);
            PLL p2 = PLL(ite2->second, ite2->first);
            PLL tmp;
            if(p1.first <= i && i < p1.second) tmp = p1;
            else tmp = p2;
            DEBUG(p1);
            DEBUG(p2);
            DEBUG(to_merge.size());
            to_merge[tmp.second].emplace_back(j, j + 1);
        }
        UnionFind uf(H);
        DEBUG(to_merge);
        for(ll j = W; j >= i + 1; j--) {
            for(PLL p : to_merge[j]) uf.unit(p.first, p.second);
            ll tmp = uf.get_max_size();
            tmp *= (j - i);
            DEBUG(i);
            DEBUG(j);
            DEBUG(uf.get_max_size());
            DEBUG(tmp);
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 62196