#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int inf = 1e9 + 5;
int tg, lb, lr[MAXN][MAXN], lc[MAXN][MAXN], sum[MAXN][MAXN];
bool val[MAXN][MAXN], arr[MAXN][MAXN], use[MAXN][MAXN];
char inp[MAXN];
int prs[MAXN][MAXN];
int my = MAXN, mx = MAXN;
int ay, ax;
int getsum(int a, int b, int c, int d) {
  return prs[c][d] - prs[a - 1][d] - prs[c][b - 1] + prs[a - 1][b - 1];
}
void precomp() {
  for (int i = 1; i <= tg; i++)
    for (int j = lb - 1; j >= 1; j--)
      if (val[i][j + 1]) lr[i][j] += lr[i][j + 1];
  for (int j = 1; j <= lb; j++)
    for (int i = tg - 1; i >= 1; i--)
      if (val[i + 1][j]) lc[i][j] += lc[i + 1][j];
}
void getans() {
  for (int i = 1; i <= tg && (my == MAXN && mx == MAXN); i++) {
    for (int j = 1; j <= lb; j++) {
      if (!val[i][j]) continue;
      if (val[i][j + 1])
        my = lc[i][j];
      else
        my = 1;
      if (val[i + 1][j])
        mx = lr[i][j];
      else
        mx = 1;
      break;
    }
  }
}
void coba_ay() {
  ay = my;
  ax = 1;
  for (int i = 1; i <= tg; i++)
    for (int j = 1; j <= lb; j++)
      if (lc[i][j] > my) ax = max(ax, lr[i][j]);
}
void coba_ax() {
  ax = mx;
  ay = 1;
  for (int i = 1; i <= tg; i++)
    for (int j = 1; j <= lb; j++)
      if (lr[i][j] > mx) ay = max(ay, lc[i][j]);
}
bool valid() {
  for (int i = 1; i <= tg; i++)
    for (int j = 1; j <= lb; j++)
      arr[i][j] = (getsum(i, j, i + ay - 1, j + ax - 1) == (ay * ax));
  int sx, sy = -1;
  for (int i = 1; i <= tg && sy == -1; i++)
    for (int j = 1; j <= lb; j++)
      if (val[i][j]) {
        sy = i;
        sx = j;
        break;
      }
  if (!arr[sy][sx]) return 0;
  memset((use), 0, sizeof((use)));
  while (1) {
    use[sy][sx] = 1;
    if (arr[sy + 1][sx] && arr[sy][sx + 1]) return 0;
    if (!arr[sy + 1][sx] && !arr[sy][sx + 1]) break;
    if (arr[sy + 1][sx])
      sy++;
    else
      sx++;
  }
  memset((sum), 0, sizeof((sum)));
  for (int i = 1; i <= tg; i++)
    for (int j = 1; j <= lb; j++) {
      if (use[i][j]) {
        sum[i][j]++;
        sum[i + ay][j]--;
        sum[i][j + ax]--;
        sum[i + ay][j + ax]++;
      }
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
      if (!sum[i][j] && val[i][j]) return 0;
    }
  return 1;
}
int main() {
  scanf("%d %d", &tg, &lb);
  memset((prs), 0, sizeof((prs)));
  for (int i = 1; i <= tg; i++) {
    scanf("%s", inp);
    for (int j = 1; j <= lb; j++) {
      val[i][j] = inp[j - 1] != '.';
      if (val[i][j]) {
        lr[i][j] = lc[i][j] = 1;
        prs[i][j] = 1;
      }
      prs[i][j] += prs[i - 1][j] + prs[i][j - 1] - prs[i - 1][j - 1];
    }
  }
  precomp();
  getans();
  int ans = inf;
  coba_ay();
  if (valid()) {
    ans = ay * ax;
  }
  coba_ax();
  if (valid()) ans = min(ans, ay * ax);
  if (ans == inf)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
