#include <bits/stdc++.h>   using namespace std;   int n, m, ans, sx, sy, ex, ey, endx = -1, endy = -1;   char s[1005][1006];   pair<int, int> xx[1005];   pair<int, int> yy[1005];   bool able(int x, int y) {     int nx = sx, ny = sy;     while (true) {       int nex = nx + x + 1, ney = ny + y + 1;       if (nex > endx && ney > endy) return true;       if (s[nx][ney] ==  X ) {         if (nex <= endx && xx[nex].first <= ny) return false;         ny++;         continue;       } else if (s[nex][ny] ==  X ) {         if (ney <= endy && yy[ney].first <= nx) return false;         nx++;         continue;       } else         return false;     }   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     int state = 0;     for (int i = 0; i < n; i++) {       xx[i].first = -1;       for (int j = 0; j < m; j++) {         if (s[i][j] ==  X ) xx[i].second = j, endx = i;         if (s[i][j] ==  X  && xx[i].first == -1) xx[i].first = j;       }       if (xx[i].first != -1) {         for (int j = xx[i].first; j <= xx[i].second; j++)           if (s[i][j] !=  X ) {             printf( -1 );             return 0;           }         if (state < 2)           state++;         else if (state == 5) {           printf( -1 );           return 0;         }       } else if (state != 0)         state = 5;       if (state != 2) continue;       if (xx[i].first < xx[i - 1].first || xx[i].second < xx[i - 1].second ||           xx[i].first > xx[i - 1].second) {         printf( -1 );         return 0;       }     }     state = 0;     for (int i = 0; i < m; i++) {       yy[i].first = -1;       for (int j = 0; j < n; j++) {         if (s[j][i] ==  X ) yy[i].second = j, endy = i;         if (s[j][i] ==  X  && yy[i].first == -1) yy[i].first = j;       }       if (yy[i].first != -1) {         for (int j = yy[i].first; j <= yy[i].second; j++)           if (s[j][i] !=  X ) {             printf( -1 );             return 0;           }         if (state < 2)           state++;         else if (state == 5) {           printf( -1 );           return 0;         }       } else if (state != 0)         state = 5;       if (state != 2) continue;       if (yy[i].first < yy[i - 1].first || yy[i].second < yy[i - 1].second ||           yy[i].first > yy[i - 1].second) {         printf( -1 );         return 0;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (s[i][j] ==  X ) {           sx = i, sy = j;           i = n;           break;         }       }     }     if (endx == -1) {       printf( 0 );       return 0;     }     for (int i = sx; i < n; i++) {       if (s[i][sy] ==  X )         ex = i;       else         break;     }     for (int i = sy; i < m; i++) {       if (s[sx][i] ==  X )         ey = i;       else         break;     }     ans = 2140000000;     for (int i = 0; i <= ex - sx; i++) {       if (able(i, ey - sy)) {         ans = min(ans, (i + 1) * (ey - sy + 1));       }     }     for (int i = 0; i <= ey - sy; i++) {       if (able(ex - sx, i)) {         ans = min(ans, (i + 1) * (ex - sx + 1));       }     }     printf( %d , ans == 2140000000 ? -1 : ans);     return 0;   }   