// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int h = input<int>();
    int w = input<int>();

    vector<string> mat(h);
    for (int i = 0; i != h; ++i)
        mat[i] = input<string>();

    int ans = max(h, w);

    vector<int> len(w - 1);
    vector<int> flag(w - 1, false);

    for (int i = 0; i != h; ++i) {
        for (int j = 0; j != w - 1; ++j) {
            if ((mat[i][j] != mat[i][j + 1]) == flag[j])
                len[j] += 1;
            else {
                len[j] = 1;
                flag[j] = (mat[i][j] != mat[i][j + 1]);
            }

//            cout << len[j] << " ";
        }
//        cout << "\n";
        
        vector<int> less_left(w - 1, -1), less_right(w - 1, w - 1);
        
        vector<int> stck;
        for (int i = 0; i != w - 1; ++i) {
            while (not stck.empty() and len[stck.back()] > len[i]) {
                less_right[stck.back()] = i;
                stck.pop_back();
            }

            stck.push_back(i);
        }

        stck.clear();
        for (int i = w - 2; i >= 0; --i) {
            while (not stck.empty() and len[stck.back()] > len[i]) {
                less_left[stck.back()] = i;
                stck.pop_back();
            }

            stck.push_back(i);
        }

        for (int i = 0; i != w - 1; ++i)
            ans = max(ans, (less_right[i] - less_left[i]) * len[i]);
    }

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 6656