#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double eps = 1e-9;
const int di[4] = {0, -1, 0, 1};
const int dj[4] = {1, 0, -1, 0};
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int area = 0;
  vector<vector<bool> > mp(n, vector<bool>(m));
  bool first = true;
  bool possible = true;
  int starti = -1;
  int startj = -1;
  vector<pair<int, int> > hz(n, pair<int, int>(-1, -1));
  vector<pair<int, int> > vt(m, pair<int, int>(-1, -1));
  vector<bool> vfinished(m, false);
  for (int i = 0; i < n; ++i) {
    bool finished = false;
    for (int j = 0; j < m; ++j) {
      char c;
      cin >> c;
      if (c == '.') {
        mp[i][j] = 0;
        if (hz[i].first != -1) {
          if (mp[i][j - 1]) hz[i].second = j - 1;
          finished = true;
        }
        if (vt[j].first != -1) {
          if (mp[i - 1][j]) vt[j].second = i - 1;
          vfinished[j] = true;
        }
      } else {
        mp[i][j] = true;
        area++;
        if (hz[i].first == -1) {
          hz[i].first = j;
          hz[i].second = j;
        } else
          hz[i].second = j;
        if (vt[j].first == -1) {
          vt[j].first = i;
          vt[j].second = i;
        } else
          vt[j].second = i;
        if (finished) {
          possible = false;
        }
        if (vfinished[j]) {
          possible = false;
        }
        if (first) {
          first = false;
          starti = i;
          startj = j;
        } else {
          bool found = false;
          for (int k = 0; k < 4; ++k) {
            int ni = i + di[k], nj = j + dj[k];
            if (ni >= 0 and ni < n and nj >= 0 and nj < m and mp[ni][nj]) {
              found = true;
            }
          }
          if (!found) possible = false;
        }
      }
    }
  }
  if (starti == -1) {
    cout << 0 << endl;
  } else if (!possible) {
    cout << -1 << endl;
  } else {
    int ans = inf;
    int initwidth = 0;
    int initheight = 0;
    for (int i = starti; i < n and mp[i][startj]; ++i) {
      ++initheight;
    }
    for (int j = startj; j < m and mp[starti][j]; ++j) {
      ++initwidth;
    }
    int height = 0;
    int width = initwidth;
    int curri = starti;
    int currj = startj;
    int endj = currj + width - 1;
    for (int i = curri; i < n and hz[i].first <= currj and hz[i].second >= endj;
         ++i) {
      ++height;
    }
    int endi = curri + height - 1;
    int currarea = width * height;
    bool nextposition = true;
    bool moveright = false;
    while ((curri + 1 < n or endj + 1 < m) and nextposition) {
      if (currarea == area) ans = min(ans, width * height);
      nextposition = false;
      bool firstmove = false;
      if (endj + 1 < m and mp[curri][endj + 1]) {
        while (!moveright and vt[endj + 1].second < endi and height > 1) {
          currarea -= width;
          height--;
          --endi;
        }
        if (vt[endj + 1].second >= endi) {
          firstmove = true;
          currarea += height;
          currj++;
          endj++;
          nextposition = true;
          moveright = true;
        }
      }
      if (!moveright and !firstmove and
          (endi + 1 >= n or hz[endi + 1].first > currj or
           hz[endi + 1].second < endj) and
          height > 1) {
        --height;
        --endi;
        currarea -= width;
        nextposition = true;
        firstmove = true;
      }
      if (!firstmove and endi + 1 < n and hz[endi + 1].first <= currj and
          hz[endi + 1].second >= endj) {
        currarea += width;
        curri++;
        endi++;
        nextposition = true;
      }
    }
    if (currarea == area) {
      ans = min(ans, width * height);
    }
    height = initheight;
    width = 0;
    curri = starti;
    currj = startj;
    endi = curri + height - 1;
    for (int j = currj; j < m and vt[j].first <= curri and vt[j].second >= endi;
         ++j) {
      ++width;
    }
    endj = currj + width - 1;
    currarea = width * height;
    nextposition = true;
    curri = starti;
    currj = startj;
    bool movedown = false;
    while ((endi + 1 < n or currj + 1 < m) and nextposition) {
      if (currarea == area) ans = min(ans, width * height);
      nextposition = false;
      bool firstmove = false;
      if (endi + 1 < n and mp[endi + 1][currj]) {
        while (!movedown and hz[endi + 1].second < endj and width > 1) {
          currarea -= height;
          width--;
          endj--;
        }
        if (hz[endi + 1].second >= endj) {
          firstmove = true;
          currarea += width;
          curri++;
          endi++;
          nextposition = true;
          movedown = true;
        }
      }
      if (!movedown and !firstmove and
          (endj + 1 >= m or vt[endj + 1].first > curri or
           vt[endj + 1].second < endi) and
          width > 1) {
        --width;
        --endj;
        currarea -= height;
        nextposition = true;
        firstmove = true;
      }
      if (!firstmove and endj + 1 < m and vt[endj + 1].first <= curri and
          vt[endj + 1].second >= endi) {
        currarea += height;
        currj++;
        endj++;
        nextposition = true;
      }
    }
    if (currarea == area) {
      ans = min(ans, width * height);
    }
    if (ans == inf)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
}
