#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

class union_find {
private:
  int component;
  std::vector<int> parent;

public:
  union_find() = default;
  union_find(int size_) { init(size_); }

  void init(int size_) {
    component = size_;
    parent.assign(size_, -1);
  }

  int count_components() const { 
    return component; 
  }
  int component_size(int i) { 
    return -parent[find_parent(i)]; 
  }
  bool same_component(int i, int j) { 
    return find_parent(i) == find_parent(j); 
  }

  int find_parent(int i) {
    if (parent[i] < 0) {
      return i;
    }
    else {
      return parent[i] = find_parent(parent[i]);
    }
  }

  bool unite(int i, int j) {
    i = find_parent(i);
    j = find_parent(j);
    if (i == j) {
      return false;
    }
    if (parent[i] > parent[j]) {
      std::swap(i, j);
    }
    parent[i] += parent[j];
    parent[j] = i;
    --component;
    return true;
  }

};

int main() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> grid(H, std::vector<char>(W));
  for (auto &v: grid) {
    for (auto &x: v) {
      std::cin >> x;
    }
  }
  std::vector<std::vector<bool>> relation(H - 1, std::vector<bool>(W));
  for (int i: range(0, H - 1)) {
    for (int j: range(0, W)) {
      relation[i][j] = (grid[i][j] == grid[i + 1][j]);
    }
  }
  std::vector<std::vector<int>> to_right(H - 1, std::vector<int>(W));
  for (int i: range(0, H - 1)) {
    to_right[i][W - 1] = 1;
    for (int j: revrange(0, W - 1)) {
      if (relation[i][j] != relation[i][j + 1]) {
        to_right[i][j] = 1;
      }
      else {
        to_right[i][j] = to_right[i][j + 1] + 1;
      }
    }
  }
  int ans = 0;
  for (int j: range(0, W)) {
    std::vector<std::vector<int>> idx(W + 1);
    for (int i: range(0, H - 1)) {
      idx[to_right[i][j]].push_back(i);
    }
    union_find dsu(H);
    int max = 1;
    for (int i: revrange(0, W + 1)) {
      for (auto x: idx[i]) {
        dsu.unite(x, x + 1);
        chmax(max, dsu.component_size(x));
      }
      chmax(ans, max * i);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 20608