#include <iostream>
using namespace std;
bool visited[99][99] = {false};
int counter = 0;
int m[99][99];
int temp;
void bola(int x, int y, int cocok, int M, int N){
if(x < 0 || y < 0 || x >= M || y >= N) {
return;
}
if(!visited[x][y] && m[x][y] == cocok){
counter+= 1;
visited[x][y] = true;
bola(x+1, y, cocok, M, N);
bola(x-1, y, cocok, M, N);
bola(x, y+1, cocok, M, N);
bola(x, y-1, cocok, M, N);
}
}
int main() {
int M, N, x, y, cocok;
cin >> M >> N;
for(int i = 0; i < M; i++){
for(int j = 0; j < N; j++){
cin >> m[i][j];
}
}
temp = 0;
for(int i = 1; i < M; i++){
for(int j = 1; j < N; j++){
if (i > 0 && j > 0 && m[i][j] != m[i-1][j-1]){
cocok = m[i-1][j-1];
bola(i-1, j-1, cocok, M, N);
int hasil = counter * (counter-1);
if (hasil > temp){
temp = hasil;
}
counter = 0;
}
}
}
cout << temp;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKYm9vbCB2aXNpdGVkWzk5XVs5OV0gPSB7ZmFsc2V9OwppbnQgY291bnRlciA9IDA7CmludCBtWzk5XVs5OV07CmludCB0ZW1wOwoKdm9pZCBib2xhKGludCB4LCBpbnQgeSwgaW50IGNvY29rLCBpbnQgTSwgaW50IE4pewoJaWYoeCA8IDAgfHwgeSA8IDAgfHwgeCA+PSBNIHx8IHkgPj0gTikgewogICAgICAgIHJldHVybjsKICAgIH0KCWlmKCF2aXNpdGVkW3hdW3ldICYmIG1beF1beV0gPT0gY29jb2spewoJCWNvdW50ZXIrPSAxOwoJCXZpc2l0ZWRbeF1beV0gPSB0cnVlOwoJCWJvbGEoeCsxLCB5LCBjb2NvaywgTSwgTik7CgkJYm9sYSh4LTEsIHksIGNvY29rLCBNLCBOKTsKCQlib2xhKHgsIHkrMSwgY29jb2ssIE0sIE4pOwoJCWJvbGEoeCwgeS0xLCBjb2NvaywgTSwgTik7Cgl9Cn0KCmludCBtYWluKCkgewoJ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