#include<bits/stdc++.h>
using namespace std;
#define _   int v, int tl, int tr, int l, int r
#define tm  (tl + tr >> 1)
#define sol v+v, tl, tm, l, r
#define sag v+v+1, tm+1, tr, l, r
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e3 + 3;    

char s[N][N];
int sam[N],dif[N];

signed main(){  
    int m,n;
    cin >> m >> n;
    for(int i=1; i<=m; i++)
        scanf(" %s", s[i]+1);
    
    int ans = max(m,n);
    for(int j=1; j<=n; j++){
        stack < pp > S;
        S.push(mp(-1,1));
        for(int i=2; i<=m+1; i++){
            int x = 0;
            if(s[i][j] == s[i-1][j]){
        		x = ++sam[i];
                dif[i] = 0;
            }   
            else{
                x = ++dif[i];
               	sam[i] = 0; 
            }
            if(i == m+1) x = 0;
            
            for(; S.top().st >= x;){
                int t = S.top().st;
                S.pop();
                ans = max(ans , t * (i-S.top().nd));
            }
            S.push(mp(x,i));
        }
    }
    
    cout << ans;
    return 0;
}
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <utility>

#define INF 1000000000

using namespace std;

typedef long long int lli;
typedef pair<int, int> P;

struct edge{
	int to, cost;
};

int V, E;
vector<edge> e[10000];
int mincost[10000];
bool used[10000];


int main(void){
	cin >> V >> E;

	for(int i = 0;i < V;i++){
		mincost[i] = INF;
		used[i] = false;
	}

	for(int i = 0;i < E;i++){
		int a, b, c;
		cin >> a >> b >> c;
		edge d;
		d.to = b;
		d.cost = c;
		e[a].push_back(d);
		d.to = a;
		e[b].push_back(d);
	}


	mincost[0] = 0;
	long long int res = 0;

	while(true){
		int v = -1;
		for(int u = 0;u < V;u++){
			if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
		}

		if(v == -1) break;
		used[v] = true;
		res += mincost[v];

		for(int u = 0;u < e[v].size();u++){
			mincost[e[v][u].to] = min(mincost[e[v][u].to], e[v][u].cost);
		}
	}
	cout << res << endl;
}